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: NodeIdThe Core state node backing this structure.
Implementations§
Source§impl<T: Clone + Send + Sync + 'static> ReactiveLog<T>
impl<T: Clone + Send + Sync + 'static> ReactiveLog<T>
Sourcepub fn new(
core: &Core,
intern: InternFn<Vec<T>>,
opts: ReactiveLogOptions<T>,
) -> Self
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.
pub fn size(&self) -> usize
pub fn at(&self, index: i64) -> Option<T>
pub fn append(&self, core: &Core, value: T)
pub fn append_many(&self, core: &Core, values: Vec<T>)
pub fn clear(&self, core: &Core)
pub fn trim_head(&self, core: &Core, n: usize)
pub fn to_vec(&self) -> Vec<T>
Sourcepub fn mutation_log_snapshot(&self) -> Option<Vec<BaseChange<LogChange<T>>>>
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>
impl<T: Clone + Send + Sync + 'static> ReactiveLog<T>
Sourcepub fn view(
&self,
core: &Core,
spec: ViewSpec,
intern: InternFn<Vec<T>>,
) -> LogView
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).
Sourcepub 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
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.
Sourcepub fn attach(
&self,
core: &Core,
upstream: NodeId,
read_value: Arc<dyn Fn(HandleId) -> T + Send + Sync>,
) -> ReactiveSub
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.
Sourcepub fn attach_with_options(
&self,
core: &Core,
upstream: NodeId,
read_value: Arc<dyn Fn(HandleId) -> T + Send + Sync>,
opts: AttachOptions,
) -> ReactiveSub
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.
Sourcepub fn attach_storage(
&self,
core: &Core,
sinks: Vec<Arc<dyn AppendLogSink<T>>>,
preload: bool,
) -> AttachStorageHandle
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.