pub trait CanonicalSerialize: Copy + Serialize + DeserializeOwned {
    type Serializer: SequenceSerializer<Self>;
    type Deserializer: SequenceDeserializer<Self>;
    type ByteReprLen: ArrayLength<u8>;
    type FromBytesError: Error + Send + Sync + 'static;

    // Required methods
    fn from_bytes(
        bytes: &GenericArray<u8, Self::ByteReprLen>
    ) -> Result<Self, Self::FromBytesError>;
    fn to_bytes(&self) -> GenericArray<u8, Self::ByteReprLen>;
}
Expand description

Types that implement this trait have a canonical serialization and a fixed serialization size.

Required Associated Types§

source

type Serializer: SequenceSerializer<Self>

A way to serialize field elements of this type.

See SequenceSerializer for more info.

source

type Deserializer: SequenceDeserializer<Self>

A way to deserialize field elements of this type.

See SequenceSerializer for more info.

source

type ByteReprLen: ArrayLength<u8>

The number of bytes in the byte representation for this element.

source

type FromBytesError: Error + Send + Sync + 'static

The error that can result from trying to decode an invalid byte sequence.

Required Methods§

source

fn from_bytes( bytes: &GenericArray<u8, Self::ByteReprLen> ) -> Result<Self, Self::FromBytesError>

Deserialize an element from a byte array.

NOTE: for security purposes, this function will accept exactly one byte sequence for each element.

source

fn to_bytes(&self) -> GenericArray<u8, Self::ByteReprLen>

Serialize an element into a byte array.

Consider using Self::Serializer if you need to serialize several field elements.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl CanonicalSerialize for F2

§

type Serializer = F2BitSerializer

§

type Deserializer = F2BitDeserializer

§

type ByteReprLen = UInt<UTerm, B1>

§

type FromBytesError = BiggerThanModulus

source§

impl CanonicalSerialize for F40b

source§

impl CanonicalSerialize for F45b

source§

impl CanonicalSerialize for F56b

source§

impl CanonicalSerialize for F61p

source§

impl CanonicalSerialize for F63b

source§

impl CanonicalSerialize for F64b

source§

impl CanonicalSerialize for F128b