Skip to main content

FieldReader

Struct FieldReader 

Source
pub struct FieldReader<'a>(/* private fields */);
Expand description

Reads one storage part’s fields in the order they were packed. Every length is checked against what remains before it is allocated, and FieldReader::finish refuses trailing bytes.

Implementations§

Source§

impl<'a> FieldReader<'a>

Source

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

Read a whole storage part, at most MAX_STORAGE bytes.

Source

pub fn u8(&mut self) -> Result<u8, Error>

A u8.

Source

pub fn u16(&mut self) -> Result<u16, Error>

A big-endian u16.

Source

pub fn text(&mut self, field: &'static str) -> Result<String, Error>

A text that is not secret, such as a bucket or folder id.

Source

pub fn secret_text(&mut self, field: &'static str) -> Result<SecretText, Error>

A secret text, such as a key or share token, erased on drop.

Source

pub fn option<T, E: From<Error>>( &mut self, get: impl FnOnce(&mut Self) -> Result<T, E>, ) -> Result<Option<T>, E>

An Option<T>: 0, or 1 and the value’s fields. Any other tag is refused. get may fail with the caller’s own error, such as a value that reads but is not valid.

Source

pub fn finish(self) -> Result<(), Error>

Refuse bytes after the last field.

Auto Trait Implementations§

§

impl<'a> Freeze for FieldReader<'a>

§

impl<'a> RefUnwindSafe for FieldReader<'a>

§

impl<'a> Send for FieldReader<'a>

§

impl<'a> Sync for FieldReader<'a>

§

impl<'a> Unpin for FieldReader<'a>

§

impl<'a> UnsafeUnpin for FieldReader<'a>

§

impl<'a> UnwindSafe for FieldReader<'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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,