Skip to main content

ByteSerializable

Trait ByteSerializable 

Source
pub trait ByteSerializable: Sized {
    type Bytes: AsRef<[u8]>;

    // Required methods
    fn to_bytes(&self) -> Self::Bytes;
    fn from_bytes(bytes: &[u8]) -> Result<Self>;
}
Expand description

Trait for types that can be serialized to a byte representation

Required Associated Types§

Source

type Bytes: AsRef<[u8]>

Owned serialized representation. Public types use Vec<u8>; secret types use exact-size zeroizing storage.

Required Methods§

Source

fn to_bytes(&self) -> Self::Bytes

Convert to a byte vector

Source

fn from_bytes(bytes: &[u8]) -> Result<Self>

Try to create from a byte slice

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl ByteSerializable for AsymmetricPublicKey<Ed25519, 32>

Source§

impl ByteSerializable for AsymmetricPublicKey<P256, 33>

Source§

impl ByteSerializable for AsymmetricPublicKey<P256, 65>

Source§

impl ByteSerializable for AsymmetricPublicKey<P384, 49>

Source§

impl ByteSerializable for AsymmetricPublicKey<P384, 97>

Source§

impl ByteSerializable for AsymmetricPublicKey<P521, 67>

Source§

impl ByteSerializable for AsymmetricPublicKey<P521, 133>

Source§

impl ByteSerializable for AsymmetricPublicKey<X25519, 32>

Source§

impl ByteSerializable for AsymmetricSecretKey<Ed25519, 32>

Source§

impl ByteSerializable for AsymmetricSecretKey<P256, 32>

Source§

impl ByteSerializable for AsymmetricSecretKey<P384, 48>

Source§

impl ByteSerializable for AsymmetricSecretKey<P521, 66>

Source§

impl ByteSerializable for AsymmetricSecretKey<X25519, 32>

Source§

impl ByteSerializable for Scalar

Source§

impl ByteSerializable for SymmetricKey<Aes128, 16>

Source§

impl ByteSerializable for SymmetricKey<Aes256, 32>

Source§

impl ByteSerializable for SymmetricKey<ChaCha20, 32>

Source§

impl ByteSerializable for SymmetricKey<ChaCha20Poly1305, 32>

Source§

impl<const N: usize> ByteSerializable for Digest<N>

Source§

impl<const N: usize> ByteSerializable for Nonce<N>

Source§

impl<const N: usize> ByteSerializable for Salt<N>

Source§

impl<const N: usize> ByteSerializable for Tag<N>