Skip to main content

RefSnapshot

Struct RefSnapshot 

Source
pub struct RefSnapshot {
    pub format_version: u16,
    pub refs: BTreeMap<String, ContentHash>,
    pub at_seq: u64,
    pub prev_snapshot: Option<ContentHash>,
}
Expand description

A signed attestation that the complete ref-state at log position RefSnapshot::at_seq was exactly RefSnapshot::refs (D25).

Carried inside OpKind::RecordRefSnapshot, and written detached — byte-identical — beside mirror bundles so a bundle is checkable against something other than itself.

The chain pointer lives inside this struct rather than being inherited from OpEntry.parent because seq/parent are assigned after signing: a snapshot copied out of the log would otherwise carry no chain of its own, and an old one could be served forever. Same discipline as the CAS prev inside a payload.

Ref names are map keys, and a git ref name may legally carry " and any non-ASCII byte (git forbids control bytes, space, ~^:?*[\, but not quotes or high bytes) — and an API-submitted name is not bound by git’s grammar at all. Canonical serialization of hostile keys is therefore pinned by this struct’s golden vector and property tests, not assumed.

Fields§

§format_version: u16

Wire-format version; see FORMAT_VERSION.

§refs: BTreeMap<String, ContentHash>

The complete ref map at at_seq, in the view’s namespaced form (<repo>:<refname>). Every ref the view holds — a selection would let an equivocating node attest only the refs it is honest about.

§at_seq: u64

The fold position the state was read at: the number of ops applied before this one. Admission requires it to equal the view’s position, so it is also the sequence this op itself occupies in the log.

§prev_snapshot: Option<ContentHash>

Content address (RefSnapshot::id) of the previous snapshot on this log; None only for a log’s first snapshot. Additive per invariant 1.

Implementations§

Source§

impl RefSnapshot

Source

pub fn canonical_bytes(&self) -> Vec<u8>

The canonical bytes: what is hashed, what the author signs over (inside the op payload), and what the detached file contains.

Source

pub fn id(&self) -> ContentHash

Content address of the canonical bytes — the identity the next snapshot’s prev_snapshot names.

Trait Implementations§

Source§

impl Clone for RefSnapshot

Source§

fn clone(&self) -> RefSnapshot

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RefSnapshot

Source§

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

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

impl<'de> Deserialize<'de> for RefSnapshot

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

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

impl PartialEq for RefSnapshot

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 RefSnapshot

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

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

impl Eq for RefSnapshot

Source§

impl StructuralPartialEq for RefSnapshot

Auto Trait Implementations§

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, 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> 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,