Skip to main content

View

Struct View 

Source
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

Source

pub const KIND: &'static str = "view"

The _kind discriminator on the wire.

Source

pub const fn new() -> Self

An empty View (no heads, no refs). The root View of a freshly- initialized repository (SPEC §7.5).

Source

pub fn with_head(self, head: Cid) -> Self

Add a head commit. Returns self for chaining.

Source

pub fn with_ref(self, name: impl Into<String>, target: RefTarget) -> Self

Add a named ref. Returns self for chaining.

Source

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).

Source

pub fn tracking_ref(&self, remote: &str, ref_name: &str) -> Option<&RefTarget>

Convenience accessor: the tracking ref the last mnem fetch recorded for a {remote, ref_name} pair, or None if the remote is unknown or does not carry that ref. Mirrors the Git behaviour of git rev-parse origin/main.

Trait Implementations§

Source§

impl Clone for View

Source§

fn clone(&self) -> View

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for View

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for View

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for View

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for View

Source§

fn eq(&self, other: &View) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for View

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for View

Source§

impl StructuralPartialEq for View

Auto Trait Implementations§

§

impl Freeze for View

§

impl RefUnwindSafe for View

§

impl Send for View

§

impl Sync for View

§

impl Unpin for View

§

impl UnsafeUnpin for View

§

impl UnwindSafe for View

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,