DelSkayn / rquickjs

High level bindings to the quickjs javascript engine
MIT License
435 stars 59 forks source link

as_bytes_mut is missing for ArrayBuffer #214

Closed stevefan1999-personal closed 7 months ago

stevefan1999-personal commented 9 months ago
    pub fn as_bytes_mut(&mut self) -> Option<&mut [u8]> {
        let (len, ptr) = Self::get_raw(self.as_value())?;
        Some(unsafe { slice::from_raw_parts_mut(ptr, len) })
    }

This is needed to implement TextEncoder

DelSkayn commented 9 months ago

The provided code would allow you to have aliasing mutable references to the same slice, by cloning the ArrayBuffer object and then calling that method on both objects. This would be unsound. I will see if I can provide a mutable way to access the bytes but it would require implementing some RefCell like functionality which is currently not present.

DelSkayn commented 7 months ago

Closing this issue as supporting the feature would be unsound.