Skip to main content

SharedSlotBuffer

Struct SharedSlotBuffer 

Source
pub struct SharedSlotBuffer<T: Copy + PartialEq + 'static> { /* private fields */ }
Expand description

A reactive typed array backed by shared memory.

  • get(index) performs a reactive read (tracks dependency via track_read)
  • set(index, value) writes to shared memory + marks reactions dirty + notifies
  • peek(index) reads without reactive tracking

The buffer owns no allocation — it operates on external memory via raw pointers.

§Type Parameters

  • T: Element type (must be Copy + PartialEq for equality checking)

Implementations§

Source§

impl<T: Copy + PartialEq + 'static> SharedSlotBuffer<T>

Source

pub unsafe fn new( ptr: *mut T, len: usize, default_value: T, notifier: impl Notifier, ) -> Self

Create a new SharedSlotBuffer over external memory.

§Safety
  • ptr must point to valid memory with at least len * size_of::<T>() bytes
  • The memory must remain valid for the lifetime of this buffer
  • If dirty is Some, it must point to valid memory with at least len bytes
Source

pub unsafe fn with_dirty( ptr: *mut T, len: usize, dirty: *mut u8, default_value: T, notifier: impl Notifier, ) -> Self

Create with dirty flags.

§Safety

Same as new(), plus dirty must point to valid memory with len bytes.

Source

pub fn get(&self, index: usize) -> T

Reactive read — tracks dependency via the reactive graph.

Source

pub fn peek(&self, index: usize) -> T

Non-reactive read.

Source

pub fn set(&self, index: usize, value: T)

Write + mark reactions dirty + set dirty flag + notify cross-side.

Source

pub fn set_batch(&self, updates: &[(usize, T)])

Batch write — single notification at end.

Source

pub fn notify_changed(&self)

Notify the Rust reactive graph that the other side changed data. Call this after waking from a cross-side notification.

Source

pub fn source(&self) -> Rc<SourceInner<u32>>

Get the coarse-grained reactive source (for building deriveds that depend on this buffer).

Source

pub fn clear(&self, index: usize)

Reset index to default value.

Source

pub fn len(&self) -> usize

Get buffer length (capacity).

Source

pub fn is_empty(&self) -> bool

Check if buffer is empty.

Auto Trait Implementations§

§

impl<T> Freeze for SharedSlotBuffer<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for SharedSlotBuffer<T>

§

impl<T> !Send for SharedSlotBuffer<T>

§

impl<T> !Sync for SharedSlotBuffer<T>

§

impl<T> Unpin for SharedSlotBuffer<T>
where T: Unpin,

§

impl<T> !UnwindSafe for SharedSlotBuffer<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.