ToFromBytes

Trait ToFromBytes 

Source
pub trait ToFromBytes:
    AsRef<[u8]>
    + Debug
    + Sized {
    // Required method
    fn from_bytes(bytes: &[u8]) -> Result<Self, FastCryptoError>;

    // Provided method
    fn as_bytes(&self) -> &[u8]  { ... }
}
Expand description

Trait impl’d by concrete types that represent digital cryptographic material (keys).

Key types must (as mandated by the AsRef<[u8]> bound) be a thin wrapper around the “bag-of-bytes” serialized form of a key which can be directly parsed from or written to the “wire”.

The ToFromBytes trait aims to provide similar simplicity by minimizing the number of steps involved to obtain a serializable key and ideally ensuring there is one signature type for any given signature system shared by all “provider” crates.

For signature systems which require a more advanced internal representation (e.g. involving decoded scalars or decompressed elliptic curve points) it’s recommended that “provider” libraries maintain their own internal signature type and use From bounds to provide automatic conversions.

Required Methods§

Source

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

Parse an object from its byte representation

Provided Methods§

Source

fn as_bytes(&self) -> &[u8]

Borrow a byte slice representing the serialized form of this object

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.

Implementors§