pub struct FilesystemBackend { /* private fields */ }Expand description
Filesystem-backed MemBackend. Mutations buffer in memory until
Self::commit, which lands them as one commit (module docs).
Implementations§
Trait Implementations§
Source§impl MemBackend for FilesystemBackend
impl MemBackend for FilesystemBackend
Source§fn current_head(&self) -> Result<Option<String>, BackendError>
fn current_head(&self) -> Result<Option<String>, BackendError>
Folder-mem drift cursor: the changelog’s last-line ts (or the
commit-pending marker while a decided commit is unapplied) — the
same RFC3339-millisecond dialect folder_changes_since accepts
as its cursor, so drift heads feed straight into delta reads.
Every mutation appends a changelog line (in this process or a
sibling’s), advancing the cursor; the drift check then treats
the advance exactly like a git-branch tip move. Absent
changelog (a mem never mutated through the engine) keeps the
historical no-drift-signal None. Appends go through
append_change_monotonic, so the cursor strictly advances even
for same-millisecond commits; only a read-append race between
separate processes can momentarily share a cursor value —
detection then rides the next append.
Source§fn write_lock_path(&self) -> Option<PathBuf>
fn write_lock_path(&self) -> Option<PathBuf>
Inside the mem’s own .memstead/, in a self-ignoring locks/
subtree, so every process that mounts this folder, from any
workspace, contends on the same file.
The path is the canonical one. Two processes that spell the
folder differently (through a symlink, through ..) must sort
their locks alike, or each takes the other’s second lock first;
and within one process the lock table is keyed by this path.
Source§fn storage_present(&self) -> Result<bool, BackendError>
fn storage_present(&self) -> Result<bool, BackendError>
Metadata-class existence probe: pending buffer first (same
precedence as read_entity), then one symlink_metadata call —
no file open, no byte read.
The mem root directory exists. A folder mount whose path is
gone (a moved checkout, a mem never materialised) lists zero
entities exactly like an empty one; this is how boot tells the
two apart.
Source§fn complete_interrupted_commit(
&self,
) -> Result<Option<CompletedCommit>, BackendError>
fn complete_interrupted_commit( &self, ) -> Result<Option<CompletedCommit>, BackendError>
Recovery writes, so it excludes a live writer first: the record it applies and the temps it removes belong to a writer that is gone only if no one holds the mem’s write lock. A record on disk waits for that lock (a live writer finishes its own commit and the record is gone by then); leftover temps are removed only if the lock is free at once, since they are invisible to readers and a load must not wait on hygiene. A mem with nothing to recover is not touched at all, lock file included.
Source§fn write_mem_config_cas(
&self,
expected: Option<&[u8]>,
bytes: &[u8],
_ctx: &CommitContext<'_>,
) -> Result<bool, BackendError>
fn write_mem_config_cas( &self, expected: Option<&[u8]>, bytes: &[u8], _ctx: &CommitContext<'_>, ) -> Result<bool, BackendError>
Compare-and-set under the mem’s config lock (an operating-system
file lock, shared with Self::write_mem_config), which is what
makes the check and the write one step. A hand edit is still
detected, because the compare reads the file. The write replaces the
file through a renamed temp, so a crash leaves the old config or the
new one.
Source§fn list_entities(&self) -> Result<Vec<PathBuf>, BackendError>
fn list_entities(&self) -> Result<Vec<PathBuf>, BackendError>
Source§fn read_entity(&self, rel_path: &Path) -> Result<Option<Vec<u8>>, BackendError>
fn read_entity(&self, rel_path: &Path) -> Result<Option<Vec<u8>>, BackendError>
rel_path. Ok(None) for a missing path
(idempotent reads); Err for IO or backend-specific failures.Source§fn entity_exists(&self, rel_path: &Path) -> Result<bool, BackendError>
fn entity_exists(&self, rel_path: &Path) -> Result<bool, BackendError>
rel_path? A pure existence
probe — the write-time cross-mem target check’s primitive:
callers verifying a reference into a mem that
is not loaded ask storage directly instead of forcing the mem’s
full load. The answer observes the same pending-buffer
precedence as Self::read_entity (a staged upsert exists, a
staged delete does not). Read moreSource§fn write_entity(
&self,
rel_path: &Path,
content: &[u8],
) -> Result<(), BackendError>
fn write_entity( &self, rel_path: &Path, content: &[u8], ) -> Result<(), BackendError>
Source§fn delete_entity(&self, rel_path: &Path) -> Result<(), BackendError>
fn delete_entity(&self, rel_path: &Path) -> Result<(), BackendError>
rel_path. Idempotent: no-op when the path is already
absent. Pending until Self::commit.Source§fn move_entity(&self, from: &Path, to: &Path) -> Result<(), BackendError>
fn move_entity(&self, from: &Path, to: &Path) -> Result<(), BackendError>
Source§fn discard_pending(&self) -> Result<(), BackendError>
fn discard_pending(&self) -> Result<(), BackendError>
batch_update stages each item’s write into the
pending set, and when a later item fails validation it calls
this to drop the already-staged writes rather than commit a
half-applied batch. Idempotent — discarding an empty buffer
is a no-op. Read moreSource§fn commit(
&self,
_message: &str,
_ctx: &CommitContext<'_>,
) -> Result<CommitId, BackendError>
fn commit( &self, _message: &str, _ctx: &CommitContext<'_>, ) -> Result<CommitId, BackendError>
CommitId; backends without history
return a synthetic id (UNIX-nanos + counter, hex) so callers
always get a non-empty cursor.Source§fn read_mem_config(&self) -> Result<Option<Vec<u8>>, BackendError>
fn read_mem_config(&self) -> Result<Option<Vec<u8>>, BackendError>
.memstead/config.json payload, if any. Read moreSource§fn write_mem_config(
&self,
bytes: &[u8],
_ctx: &CommitContext<'_>,
) -> Result<(), BackendError>
fn write_mem_config( &self, bytes: &[u8], _ctx: &CommitContext<'_>, ) -> Result<(), BackendError>
.memstead/config.json payload. Symmetric
counterpart to Self::read_mem_config. Read moreSource§fn read_anchors_sidecar(&self) -> Result<Option<Vec<u8>>, BackendError>
fn read_anchors_sidecar(&self) -> Result<Option<Vec<u8>>, BackendError>
crate::anchor::ANCHOR_SIDECAR_PATH) bytes, if any. Read moreSource§fn write_anchors_sidecar(&self, bytes: &[u8]) -> Result<(), BackendError>
fn write_anchors_sidecar(&self, bytes: &[u8]) -> Result<(), BackendError>
Source§fn stage_provenance(&self, record: &Provenance) -> Result<(), BackendError>
fn stage_provenance(&self, record: &Provenance) -> Result<(), BackendError>
Provenance record so it lands with the next
Self::commit and never without it: the record of a write
belongs to that write. Pending like the entity writes, and
dropped by Self::discard_pending and by a failed commit. Read moreSource§fn append_provenance(&self, record: &Provenance) -> Result<(), BackendError>
fn append_provenance(&self, record: &Provenance) -> Result<(), BackendError>
Provenance record to the backend’s mutation log at
once, outside any commit: the form for an event that writes no
file (dropping a stub, a review mark). A record that describes a
commit goes through Self::stage_provenance instead.
Persistence form differs per backend — JSONL line, commit
trailer, etc. — but the in-memory shape is identical.Source§fn read_provenance(
&self,
cursor: Option<&str>,
) -> Result<Vec<Provenance>, BackendError>
fn read_provenance( &self, cursor: Option<&str>, ) -> Result<Vec<Provenance>, BackendError>
cursor (opaque,
backend-defined: a commit SHA for git-branch, an RFC-3339
timestamp for folder, ignored for archive). None cursor
means “from the beginning”.Source§fn read_all_entities(&self) -> Result<Vec<EntityRead>, BackendError>
fn read_all_entities(&self) -> Result<Vec<EntityRead>, BackendError>
Ok(bytes) or the per-path read failure, so a
caller can carry on past one unreadable entity; a path listed
but gone by read time is dropped (list/read race). The outer
Err is a listing failure. Order is not specified. Read moreSource§fn commit_with_expected_parent(
&self,
message: &str,
ctx: &CommitContext<'_>,
_expected_parent: Option<&str>,
) -> Result<CommitId, BackendError>
fn commit_with_expected_parent( &self, message: &str, ctx: &CommitContext<'_>, _expected_parent: Option<&str>, ) -> Result<CommitId, BackendError>
expected_parent is Some, the backend MUST refuse the
commit (Err(BackendError::ParentMismatch { ... })) if its
current head no longer matches the supplied ref — a sibling
writer advanced the on-disk state between the snapshot the
caller pinned and now. When expected_parent is None, the
call is equivalent to Self::commit. Read moreSource§fn read_archive_provenance(&self) -> Result<Option<Vec<u8>>, BackendError>
fn read_archive_provenance(&self) -> Result<Option<Vec<u8>>, BackendError>
.memstead/provenance.json) the archive carries, if any. Read moreSource§fn read_archive_checks(&self) -> Result<Option<Vec<u8>>, BackendError>
fn read_archive_checks(&self) -> Result<Option<Vec<u8>>, BackendError>
.memstead/checks.json) the archive carries, if any. Read moreSource§fn read_proposal_record(&self) -> Result<Option<Vec<u8>>, BackendError>
fn read_proposal_record(&self) -> Result<Option<Vec<u8>>, BackendError>
crate::ops::proposal::PROPOSAL_RECORD_PATH) bytes, if any:
the sidecar a proposal merge writes on the target branch, keyed
by proposal id with every disposition. The default reads the
path through Self::read_entity, which is the git-branch
backend’s tree read; the archive backend overrides to read the
sealed member. Ok(None) for a mem no proposal was ever merged
into.Source§fn record_pipeline_edit(
&self,
_kind: &str,
_edits: &[(String, Option<Vec<u8>>)],
_ctx: &CommitContext<'_>,
_verb: &str,
) -> Result<(), BackendError>
fn record_pipeline_edit( &self, _kind: &str, _edits: &[(String, Option<Vec<u8>>)], _ctx: &CommitContext<'_>, _verb: &str, ) -> Result<(), BackendError>
.memstead/ on the workspace root — it has no
commit of its own — so backends with a commit timeline mirror the
edit into their provenance record; the commit is the audit trail,
the disk file stays the read path. Read moreSource§fn delete_artifacts(&self, ctx: &CommitContext<'_>) -> Result<(), BackendError>
fn delete_artifacts(&self, ctx: &CommitContext<'_>) -> Result<(), BackendError>
memstead_mem_create (entity-seed commit on the per-mem
branch + Self::write_mem_config on __MEMSTEAD). Called by
memstead_mem_delete orchestration when delete_files=true and
the delete rule matched, to give the backend a chance to
prune ref-store state the engine alone has the git authority
to touch. Read moreAuto Trait Implementations§
impl !Freeze for FilesystemBackend
impl !RefUnwindSafe for FilesystemBackend
impl !UnwindSafe for FilesystemBackend
impl Forget for FilesystemBackend
impl Move for FilesystemBackend
impl Send for FilesystemBackend
impl Sync for FilesystemBackend
impl Unpin for FilesystemBackend
impl UnsafeUnpin for FilesystemBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more