Skip to main content

PackReader

Struct PackReader 

Source
pub struct PackReader<'a> { /* private fields */ }
Expand description

A pack as it reads: its space, the update that wrote it, and its items, one after the other, each checked as it is read.

Implementations§

Source§

impl<'a> PackReader<'a>

Source

pub fn new(bytes: &'a [u8]) -> Result<Self, SyncError>

Starts reading a pack from its bytes.

§Errors

Returns SyncError::Protocol if the bytes do not start with a pack’s first value.

Source

pub fn item_at(space: SpaceId, bytes: &[u8]) -> Result<PackItem, SyncError>

The item whose encoding bytes holds whole, as PackReader::next_item found it in a pack of space.

§Errors

Returns SyncError::Protocol if bytes is not exactly one such item.

Source

pub const fn space(&self) -> SpaceId

The space whose items the pack holds.

Source

pub const fn update(&self) -> u64

The number of the update that wrote the pack.

Source

pub fn next_item( &mut self, ) -> Result<Option<(PackItem, usize, usize)>, SyncError>

The next item, with where its encoding starts in the pack and how long it is, or None at the pack’s end.

§Errors

Returns SyncError::Protocol if what follows is no item of the pack’s space, or a blob whose bytes do not have its sealed hash, or is larger than MOST_PACK_BLOB.

Auto Trait Implementations§

§

impl<'a> Forget for PackReader<'a>

§

impl<'a> Freeze for PackReader<'a>

§

impl<'a> Move for PackReader<'a>

§

impl<'a> RefUnwindSafe for PackReader<'a>

§

impl<'a> Send for PackReader<'a>

§

impl<'a> Sync for PackReader<'a>

§

impl<'a> Unpin for PackReader<'a>

§

impl<'a> UnsafeUnpin for PackReader<'a>

§

impl<'a> UnwindSafe for PackReader<'a>

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> ErasedDestructor for T
where T: 'static,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.