pub struct View {
pub heads: Vec<Cid>,
pub refs: BTreeMap<String, RefTarget>,
pub remote_refs: Option<BTreeMap<String, BTreeMap<String, RefTarget>>>,
pub wc_commit: Option<Cid>,
pub tombstones: BTreeMap<NodeId, Tombstone>,
pub extra: BTreeMap<String, Ipld>,
}Expand description
A snapshot of the repository’s mutable state at a single instant.
Fields§
§heads: Vec<Cid>Current head commits.
refs: BTreeMap<String, RefTarget>Named references.
remote_refs: Option<BTreeMap<String, BTreeMap<String, RefTarget>>>Per-remote named references. Outer key is the remote name
(e.g. "origin" matching a [remote.origin] section in
.mnem/config.toml); inner map is that remote’s server-side
refs (e.g. "refs/heads/main" → RefTarget) as observed on
the last mnem fetch. PR 2 on the remote-transport track
adds the View::with_tracking_ref / View::tracking_ref
helpers; PR 3 wires up the actual network fetch. Absent /
empty maps are omitted from the wire encoding so pre-0.3
Views round-trip byte-identically. See .
wc_commit: Option<Cid>Working-copy commit pointer.
tombstones: BTreeMap<NodeId, Tombstone>Logical “forget this node” markers (SPEC §4.10, mnem/0.2+).
Maps a NodeId to the Tombstone record that revoked it.
The underlying Node block stays in the node Prolly tree; its CID
is unchanged. Retrieval paths filter out tombstoned nodes by
default (see
crate::retrieve::Retriever::include_tombstoned).
Re-tombstoning the same NodeId overwrites the previous entry.
Store shape mirrors remote_refs: inline BTreeMap, encoded as
an optional list that is skipped on the wire when empty. That
keeps pre-0.2 Views byte-identical after a round-trip through a
newer decoder.
extra: BTreeMap<String, Ipld>Forward-compat extension map (SPEC §3.2).
Implementations§
Source§impl View
impl View
Sourcepub const fn new() -> Self
pub const fn new() -> Self
An empty View (no heads, no refs). The root View of a freshly- initialized repository (SPEC §7.5).
Sourcepub fn with_ref(self, name: impl Into<String>, target: RefTarget) -> Self
pub fn with_ref(self, name: impl Into<String>, target: RefTarget) -> Self
Add a named ref. Returns self for chaining.
Sourcepub fn with_tracking_ref(
self,
remote: impl Into<String>,
ref_name: impl Into<String>,
target: Cid,
) -> Self
pub fn with_tracking_ref( self, remote: impl Into<String>, ref_name: impl Into<String>, target: Cid, ) -> Self
Record a tracking ref for a named remote, e.g. after a mnem fetch origin converges the server’s refs/heads/main to a
local origin/main pointer. remote is the short name
registered in .mnem/config.toml ([remote.origin]),
ref_name is the server-side refname (refs/heads/main),
and target is the Commit CID the remote had for it at fetch
time. Subsequent fetches overwrite.
Returns self for chaining. Lazily allocates the
remote_refs map; empty Views still encode to the pre-0.3
byte sequence (the map is omitted when empty).