Struct Snapshot

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

The Snapshot API manages serialization and deserialization of collections of objects that implement the Versionize trait.

Implementations§

Source§

impl Snapshot

Source

pub fn new(version_map: VersionMap, target_version: u16) -> Snapshot

Creates a new instance which can only be used to save a new snapshot.

Source

pub fn get_data_version<T>( reader: &mut T, version_map: &VersionMap, ) -> Result<u16, Error>
where T: Read + Debug,

Fetches snapshot data version.

Source

pub fn unchecked_load<T: Read + Debug, O: Versionize + Debug>( reader: &mut T, version_map: VersionMap, ) -> Result<(O, u16), Error>

Attempts to load an existing snapshot without CRC validation.

Source

pub fn load<T: Read + Debug, O: Versionize + Debug>( reader: &mut T, snapshot_len: usize, version_map: VersionMap, ) -> Result<(O, u16), Error>

Attempts to load an existing snapshot and validate CRC.

Source

pub fn save<T, O>(&mut self, writer: &mut T, object: &O) -> Result<(), Error>
where T: Write + Debug, O: Versionize + Debug,

Saves a snapshot and include a CRC64 checksum.

Source

pub fn save_without_crc<T, O>( &mut self, writer: &mut T, object: &O, ) -> Result<(), Error>
where T: Write, O: Versionize + Debug,

Save a snapshot with no CRC64 checksum included.

Trait Implementations§

Source§

impl Debug for Snapshot

Source§

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

Formats the value using the given formatter. Read more

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