pub struct ReactiveSharedArray<T: Copy> { /* private fields */ }Expand description
A reactive array backed by shared memory.
Reads from this array can trigger reactive subscriptions. The array is read-only from Rust’s perspective - writes come from the TypeScript side.
§Type Parameters
T: The element type (must be Copy for safe shared memory access)
Implementations§
Sourcepub unsafe fn new(ptr: *const T, len: usize, dirty: *const u8) -> Self
pub unsafe fn new(ptr: *const T, len: usize, dirty: *const u8) -> Self
Create a new reactive shared array.
§Safety
ptrmust point to valid shared memory with at leastlen * size_of::<T>()bytesdirtymust point to valid shared memory with at leastlenbytes- Both pointers must remain valid for the lifetime of this array
Sourcepub unsafe fn from_context(
ctx: &SharedBufferContext,
byte_offset: usize,
len: usize,
) -> Self
pub unsafe fn from_context( ctx: &SharedBufferContext, byte_offset: usize, len: usize, ) -> Self
Create from a SharedBufferContext with byte offset.
§Safety
- The offset must be properly aligned for type T
- The region must not overlap with other mutable regions
Sourcepub fn clear_dirty(&self, index: usize)
pub fn clear_dirty(&self, index: usize)
Clear the dirty flag for an index.
Sourcepub fn dirty_indices(&self) -> Vec<usize>
pub fn dirty_indices(&self) -> Vec<usize>
Get all dirty indices.
Sourcepub fn bump_version(&self)
pub fn bump_version(&self)
Increment version (called when processing changes).
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more