Skip to main content

ReactiveLog

Struct ReactiveLog 

Source
pub struct ReactiveLog<T: Clone + Send + Sync + 'static> {
    pub node_id: NodeId,
    /* private fields */
}
Expand description

Reactive append-only log with optional ring-buffer cap.

Emits Vec<T> snapshots via a Core state node on every mutation. Optionally records BaseChange<LogChange<T>> deltas to a companion mutation log.

Fields§

§node_id: NodeId

The Core state node backing this structure.

Implementations§

Source§

impl<T: Clone + Send + Sync + 'static> ReactiveLog<T>

Source

pub fn new( core: &Core, intern: InternFn<Vec<T>>, opts: ReactiveLogOptions<T>, ) -> Self

Create a new reactive log registered with the given Core.

intern converts a Vec<T> snapshot to a HandleId for Core emission.

Source

pub fn size(&self) -> usize

Source

pub fn at(&self, index: i64) -> Option<T>

Source

pub fn append(&self, core: &Core, value: T)

Source

pub fn append_many(&self, core: &Core, values: Vec<T>)

Source

pub fn clear(&self, core: &Core)

Source

pub fn trim_head(&self, core: &Core, n: usize)

Source

pub fn to_vec(&self) -> Vec<T>

Source

pub fn mutation_log_snapshot(&self) -> Option<Vec<BaseChange<LogChange<T>>>>

Snapshot the mutation log (if enabled). Returns None if mutation log was not enabled at construction.

Source§

impl<T: Clone + Send + Sync + 'static> ReactiveLog<T>

Source

pub fn view( &self, core: &Core, spec: ViewSpec, intern: InternFn<Vec<T>>, ) -> LogView

Create a reactive view of this log. Returns a LogView whose node_id emits Vec<T> snapshots on every log mutation.

intern converts the view Vec<T> into a HandleId for Core emission. β/D231/D246: takes the owner’s &Core (no stored Core under the actor model). The returned LogView carries no Core borrow; tear it down via LogView::detach (D246 r3 — no RAII).

Source

pub fn scan<TAcc: Clone + Send + Sync + 'static>( &self, core: &Core, initial: TAcc, step: Arc<dyn Fn(&TAcc, &T) -> TAcc + Send + Sync>, intern: InternFn<TAcc>, ) -> ScanHandle

Incremental running aggregate over the log.

Returns a ScanHandle whose node_id emits the current accumulator on every log mutation. Appends are O(1) (only new entries processed); trimHead/clear trigger a full rescan.

Source

pub fn attach( &self, core: &Core, upstream: NodeId, read_value: Arc<dyn Fn(HandleId) -> T + Send + Sync>, ) -> ReactiveSub

Subscribe to an upstream node and append every DATA value into this log.

read_value converts the upstream HandleId to a T for appending. Returns a ReactiveSub — call ReactiveSub::detach to stop the attachment (D246 r3 — no RAII). β/D231: takes the owner’s &Core.

Source

pub fn attach_with_options( &self, core: &Core, upstream: NodeId, read_value: Arc<dyn Fn(HandleId) -> T + Send + Sync>, opts: AttachOptions, ) -> ReactiveSub

D270 — variant of Self::attach accepting AttachOptions. Use when you need skip_cached_replay or future attach knobs; the no-option attach delegates here with AttachOptions::default() for back-compat callers.

Source

pub fn attach_storage( &self, core: &Core, sinks: Vec<Arc<dyn AppendLogSink<T>>>, preload: bool, ) -> AttachStorageHandle

Wire append-log storage sinks to this log.

If preload is true, attempts load_entries() on the first sink that returns data and appends to this log before subscribing. After subscription, deltas are forwarded to ALL sinks. On trim/clear, the full snapshot is re-shipped. Sink errors are swallowed (logged via eprintln!) so a failing tier doesn’t break the reactive graph.

Auto Trait Implementations§

§

impl<T> !Freeze for ReactiveLog<T>

§

impl<T> !RefUnwindSafe for ReactiveLog<T>

§

impl<T> Send for ReactiveLog<T>

§

impl<T> Sync for ReactiveLog<T>

§

impl<T> Unpin for ReactiveLog<T>

§

impl<T> UnsafeUnpin for ReactiveLog<T>

§

impl<T> !UnwindSafe for ReactiveLog<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> Same for T

Source§

type Output = T

Should always be Self
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.