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, value: T)
pub fn append_many(&self, values: Vec<T>)
pub fn clear(&self)
pub fn trim_head(&self, 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, spec: ViewSpec, intern: InternFn<Vec<T>>) -> LogView
pub fn view(&self, 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.
Sourcepub fn scan<TAcc: Clone + Send + Sync + 'static>(
&self,
initial: TAcc,
step: Arc<dyn Fn(&TAcc, &T) -> TAcc + Send + Sync>,
intern: InternFn<TAcc>,
) -> ScanHandle
pub fn scan<TAcc: Clone + Send + Sync + 'static>( &self, 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,
upstream: NodeId,
read_value: Arc<dyn Fn(HandleId) -> T + Send + Sync>,
) -> Subscription
pub fn attach( &self, upstream: NodeId, read_value: Arc<dyn Fn(HandleId) -> T + Send + Sync>, ) -> Subscription
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 Subscription — dropping it stops the attachment.
Sourcepub fn attach_storage(
&self,
sinks: Vec<Arc<dyn AppendLogSink<T>>>,
preload: bool,
) -> AttachStorageHandle
pub fn attach_storage( &self, 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.