pub struct VecSidecar<T> { /* private fields */ }Expand description
Atomic JSON sidecar specialized to a Vec<T> document — the shape every
_system/ row table uses (CDC checkpoints, scheduler jobs, deferred
triggers, declared plugins).
Wraps SystemSidecar and adds the two conveniences every row-table caller
re-rolled by hand: Self::load returns an empty Vec for an absent /
empty file, and Self::store takes a borrowed &[T] so a caller that
already owns a Vec<T> (or a sub-slice) persists it without an intermediate
clone.
Implementations§
Source§impl<T> VecSidecar<T>
impl<T> VecSidecar<T>
Sourcepub fn new(data_path: impl AsRef<Path>, file_name: &str) -> Self
pub fn new(data_path: impl AsRef<Path>, file_name: &str) -> Self
Construct rooted at <data_path>/_system/<file_name>.
file_name must match the on-disk name the subsystem has always used —
changing it would orphan existing state across an upgrade.
Sourcepub fn load(&self) -> Result<Vec<T>, SidecarIoError>where
T: DeserializeOwned,
pub fn load(&self) -> Result<Vec<T>, SidecarIoError>where
T: DeserializeOwned,
Load the persisted rows, or an empty Vec if the file is absent or empty.
§Errors
Returns SidecarIoError::Read on IO failure or
SidecarIoError::Decode when the file is present but not valid JSON.
Sourcepub fn store(&self, rows: &[T]) -> Result<(), SidecarIoError>where
T: Serialize,
pub fn store(&self, rows: &[T]) -> Result<(), SidecarIoError>where
T: Serialize,
Atomically replace the persisted rows with rows.
Takes a borrowed slice so callers that already own a Vec<T> persist it
without cloning.
§Errors
Same as SystemSidecar::store.
Trait Implementations§
Source§impl<T: Clone> Clone for VecSidecar<T>
impl<T: Clone> Clone for VecSidecar<T>
Source§fn clone(&self) -> VecSidecar<T>
fn clone(&self) -> VecSidecar<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more