tafrah-traits 0.1.8

Shared traits and error types for the Tafrah PQC library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Lightweight encoding and decoding traits.

#[cfg(feature = "alloc")]
use alloc::vec::Vec;

#[cfg(feature = "alloc")]
/// Serializes a value into an owned byte vector.
pub trait Encode {
    fn to_bytes(&self) -> Vec<u8>;
}

#[cfg(feature = "alloc")]
/// Decodes a value from a serialized byte slice.
pub trait Decode: Sized {
    type Error;
    fn from_bytes(bytes: &[u8]) -> Result<Self, Self::Error>;
}