1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! Mem write-side trait. The [`MemWriter`] surface is
//! backend-neutral: it deals in mem-relative paths, raw bytes, and
//! opaque [`CommitId`] strings. Two adapters live in the workspace
//! today: the git-tree adapter in `memstead_git_branch::storage::git_tree`
//! (mem-repo writes) and [`filesystem::FilesystemMemWriter`]
//! in this crate (filesystem-only writes — no gix, no commit
//! history).
//!
//! # Trait surface
//!
//! Four operations cover today's mutation surface:
//! - [`MemWriter::write_entity`] — upsert raw bytes at a mem-relative path.
//! - [`MemWriter::delete_entity`] — remove a mem-relative path.
//! - [`MemWriter::move_entity`] — rename within the mem.
//! - [`MemWriter::commit`] — flush pending mutations into a single commit.
//!
//! # Errors
//!
//! All four methods return [`MemWriterError`]. Engine-layer code in
//! `memstead-git-branch` wraps this into its `EngineError::MemWriter` (a
//! `#[from]` conversion) and the MCP layer wraps it as a
//! `MEM_WRITER_ERROR`-coded envelope.
pub use ArchiveBackend;
pub use FilesystemMemWriter;
pub use InMemoryBackend;
use Path;
use crateCommitContext;
/// Opaque commit identifier returned by [`MemWriter::commit`].
/// Backend-defined string — the git-tree adapter formats it as a
/// hex-encoded object id (40 chars for sha-1, 64 for sha-256), but the
/// trait surface treats it as opaque. Callers carry it back into the
/// engine's `HashMismatch.current` envelope when the adapter detects a
/// CAS conflict.
pub type CommitId = String;
/// Write-side abstraction for mem content. Implementations are
/// `Send + Sync` so the engine can hold a `Box<dyn MemWriter>` on
/// each `MemState` and reach it from any caller.
/// Errors surfaced by [`MemWriter`].