Trait winter_verifier::Deserializable
source · pub trait Deserializable: Sized {
fn read_from<R>(source: &mut R) -> Result<Self, DeserializationError>
where
R: ByteReader;
fn read_batch_from<R>(
source: &mut R,
num_elements: usize
) -> Result<Vec<Self, Global>, DeserializationError>
where
R: ByteReader,
{ ... }
}
Expand description
Defines how to deserialize Self
from bytes.
Required Methods
sourcefn read_from<R>(source: &mut R) -> Result<Self, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<Self, DeserializationError>where
R: ByteReader,
Reads a sequence of bytes from the provided source
, attempts to deserialize these bytes
into Self
, and returns the result.
Errors
Returns an error if:
- The
source
does not contain enough bytes to deserializeSelf
. - Bytes read from the
source
do not represent a valid value forSelf
.
Provided Methods
sourcefn read_batch_from<R>(
source: &mut R,
num_elements: usize
) -> Result<Vec<Self, Global>, DeserializationError>where
R: ByteReader,
fn read_batch_from<R>(
source: &mut R,
num_elements: usize
) -> Result<Vec<Self, Global>, DeserializationError>where
R: ByteReader,
Reads a sequence of bytes from the provided source
, attempts to deserialize these bytes
into a vector with the specified number of Self
elements, and returns the result.
Errors
Returns an error if:
- The
source
does not contain enough bytes to deserialize the specified number of elements. - Bytes read from the
source
do not represent a valid value forSelf
for any of the elements.
Note: if the error occurs, the reader is not rolled back to the state prior to calling this function.
Implementations on Foreign Types
sourceimpl Deserializable for OodFrame
impl Deserializable for OodFrame
sourcefn read_from<R>(source: &mut R) -> Result<OodFrame, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<OodFrame, DeserializationError>where
R: ByteReader,
Reads a OOD frame from the specified source
and returns the result
Errors
Returns an error of a valid OOD frame could not be read from the specified source
.
sourceimpl Deserializable for Commitments
impl Deserializable for Commitments
sourcefn read_from<R>(source: &mut R) -> Result<Commitments, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<Commitments, DeserializationError>where
R: ByteReader,
Reads commitments from the specified source
and returns the result.
Errors
Returns an error of a valid Commitments struct could not be read from the specified
source
.
sourceimpl Deserializable for Queries
impl Deserializable for Queries
sourcefn read_from<R>(source: &mut R) -> Result<Queries, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<Queries, DeserializationError>where
R: ByteReader,
Reads a query struct from the specified source
and returns the result
Errors
Returns an error of a valid query struct could not be read from the specified source.
sourceimpl Deserializable for TraceLayout
impl Deserializable for TraceLayout
sourcefn read_from<R>(source: &mut R) -> Result<TraceLayout, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<TraceLayout, DeserializationError>where
R: ByteReader,
Reads TraceLayout from the specified source
and returns the result.
Errors
Returns an error of a valid TraceLayout struct could not be read from the specified
source
.
sourceimpl Deserializable for Context
impl Deserializable for Context
sourcefn read_from<R>(source: &mut R) -> Result<Context, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<Context, DeserializationError>where
R: ByteReader,
Reads proof context from the specified source
and returns the result.
Errors
Returns an error of a valid Context struct could not be read from the specified source
.
sourceimpl Deserializable for FriProof
impl Deserializable for FriProof
sourcefn read_from<R>(source: &mut R) -> Result<FriProof, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<FriProof, DeserializationError>where
R: ByteReader,
Reads a FRI proof from the specified source
and returns the result.
Errors
Returns an error if a valid proof could not be read from the source.