Skip to main content

Checkpoint

Struct Checkpoint 

Source
pub struct Checkpoint { /* private fields */ }
Expand description

A Checkpoint is a tree head to be formatted according to c2sp.org/checkpoint.

Implementations§

Source§

impl Checkpoint

Source

pub fn origin(&self) -> &str

Return the checkpoint’s origin.

Source

pub fn size(&self) -> u64

Return the size of the checkpoint’s tree.

Source

pub fn hash(&self) -> &Hash

Return the root hash of the checkpoint’s tree.

Source

pub fn extension(&self) -> &str

Return the checkpoint’s extensions.

Source

pub fn new( origin: &str, size: u64, hash: Hash, extension: &str, ) -> Result<Self, MalformedCheckpointError>

Return a new checkpoint with the given arguments.

§Errors

Returns a MalformedCheckpointError if the arguments do not comply with the C2SP tlog-checkpoint specification.

Source

pub fn from_bytes(text: &[u8]) -> Result<Self, MalformedCheckpointError>

Parse a checkpoint from encoded bytes.

§Errors

Returns an error if the checkpoint is malformed.

Source

pub fn from_reader<R: BufRead>( reader: &mut R, strict: bool, ) -> Result<Self, MalformedCheckpointError>

Parse a checkpoint from encoded bytes reader. If strict is set to true, the reader should exactly match a checkpoint. Otherwise, read until we encounter a blank line (only a newline).

§Errors

Returns an error if the checkpoint is malformed.

Source

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

Returns an encoded checkpoint.

Trait Implementations§

Source§

impl Debug for Checkpoint

Source§

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

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

impl PartialEq for Checkpoint

Source§

fn eq(&self, other: &Checkpoint) -> 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 StructuralPartialEq for Checkpoint

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.