pub trait Deserializable: Sized {
// Required method
fn read_from<R>(source: &mut R) -> Result<Self, DeserializationError>
where R: ByteReader;
// Provided method
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError> { ... }
}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
sourcedoes not contain enough bytes to deserializeSelf. - Bytes read from the
sourcedo not represent a valid value forSelf.
Provided Methods§
Sourcefn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
Attempts to deserialize the provided bytes into Self and returns the result.
§Errors
Returns an error if:
- The
bytesdo not contain enough information to deserializeSelf. - The
bytesdo not represent a valid value forSelf.
Note: if bytes contains more data than needed to deserialize self, no error is
returned.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl Deserializable for HashFunction
impl Deserializable for HashFunction
fn read_from<R>(source: &mut R) -> Result<HashFunction, DeserializationError>where
R: ByteReader,
Source§impl Deserializable for Operation
impl Deserializable for Operation
fn read_from<R>(source: &mut R) -> Result<Operation, DeserializationError>where
R: ByteReader,
Source§impl Deserializable for BatchingMethod
impl Deserializable for BatchingMethod
Source§fn read_from<R>(source: &mut R) -> Result<BatchingMethod, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<BatchingMethod, DeserializationError>where
R: ByteReader,
Reads BatchingMethod from the specified source and returns the result.
§Errors
Returns an error if the value does not correspond to a valid BatchingMethod.
Source§impl Deserializable for FieldExtension
impl Deserializable for FieldExtension
Source§fn read_from<R>(source: &mut R) -> Result<FieldExtension, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<FieldExtension, DeserializationError>where
R: ByteReader,
Reads a field extension enum from the specified source.
Source§impl Deserializable for u8
impl Deserializable for u8
fn read_from<R>(source: &mut R) -> Result<u8, DeserializationError>where
R: ByteReader,
Source§impl Deserializable for u16
impl Deserializable for u16
fn read_from<R>(source: &mut R) -> Result<u16, DeserializationError>where
R: ByteReader,
Source§impl Deserializable for u32
impl Deserializable for u32
fn read_from<R>(source: &mut R) -> Result<u32, DeserializationError>where
R: ByteReader,
Source§impl Deserializable for u64
impl Deserializable for u64
fn read_from<R>(source: &mut R) -> Result<u64, DeserializationError>where
R: ByteReader,
Source§impl Deserializable for u128
impl Deserializable for u128
fn read_from<R>(source: &mut R) -> Result<u128, DeserializationError>where
R: ByteReader,
Source§impl Deserializable for ()
impl Deserializable for ()
fn read_from<R>(_source: &mut R) -> Result<(), DeserializationError>where
R: ByteReader,
Source§impl Deserializable for usize
impl Deserializable for usize
fn read_from<R>(source: &mut R) -> Result<usize, DeserializationError>where
R: ByteReader,
Source§impl Deserializable for String
impl Deserializable for String
fn read_from<R>(source: &mut R) -> Result<String, DeserializationError>where
R: ByteReader,
Source§impl Deserializable for PublicInputs
impl Deserializable for PublicInputs
fn read_from<R>(source: &mut R) -> Result<PublicInputs, DeserializationError>where
R: ByteReader,
Source§impl Deserializable for Kernel
impl Deserializable for Kernel
fn read_from<R>(source: &mut R) -> Result<Kernel, DeserializationError>where
R: ByteReader,
Source§impl Deserializable for TraceInfo
impl Deserializable for TraceInfo
Source§impl Deserializable for ProofOptions
impl Deserializable for ProofOptions
Source§fn read_from<R>(source: &mut R) -> Result<ProofOptions, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<ProofOptions, DeserializationError>where
R: ByteReader,
Reads proof options from the specified source and returns the result.
§Errors
Returns an error of a valid proof options could not be read from the specified source.
Source§impl Deserializable for Commitments
impl Deserializable for Commitments
Source§fn 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.
Source§impl Deserializable for Context
impl Deserializable for Context
Source§fn 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.
Source§impl Deserializable for OodFrame
impl Deserializable for OodFrame
Source§fn 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.
Source§impl Deserializable for Queries
impl Deserializable for Queries
Source§fn 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.
Source§impl Deserializable for Proof
impl Deserializable for Proof
fn read_from<R>(source: &mut R) -> Result<Proof, DeserializationError>where
R: ByteReader,
Source§impl Deserializable for FriProof
impl Deserializable for FriProof
Source§fn 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.
Source§impl Deserializable for BaseElement
impl Deserializable for BaseElement
fn read_from<R>(source: &mut R) -> Result<BaseElement, DeserializationError>where
R: ByteReader,
Source§impl Deserializable for BaseElement
impl Deserializable for BaseElement
fn read_from<R>(source: &mut R) -> Result<BaseElement, DeserializationError>where
R: ByteReader,
Source§impl<B> Deserializable for CubeExtension<B>where
B: ExtensibleField<3>,
impl<B> Deserializable for CubeExtension<B>where
B: ExtensibleField<3>,
fn read_from<R>(
source: &mut R,
) -> Result<CubeExtension<B>, DeserializationError>where
R: ByteReader,
Source§impl<B> Deserializable for QuadExtension<B>where
B: ExtensibleField<2>,
impl<B> Deserializable for QuadExtension<B>where
B: ExtensibleField<2>,
fn read_from<R>(
source: &mut R,
) -> Result<QuadExtension<B>, DeserializationError>where
R: ByteReader,
Source§impl<H> Deserializable for BatchMerkleProof<H>where
H: Hasher,
impl<H> Deserializable for BatchMerkleProof<H>where
H: Hasher,
Source§fn read_from<R>(
source: &mut R,
) -> Result<BatchMerkleProof<H>, DeserializationError>where
R: ByteReader,
fn read_from<R>(
source: &mut R,
) -> Result<BatchMerkleProof<H>, DeserializationError>where
R: ByteReader,
Parses internal nodes from the provided source, and constructs a batch Merkle proof
from these nodes.
§Errors
Returns an error if:
sourcecould not be deserialized into a valid set of internal nodes.