pub trait Symbol<const N: usize> {
// Required methods
fn to_bytes(&self) -> [u8; N];
fn from_bytes(bytes: &[u8; N]) -> Self;
}Expand description
A trait to implement on everything that can be an item for a Encoder or a Decoder.
Example implementation for u64:
impl Symbol<8> for u64 {
fn to_bytes(&self) -> [u8; 8] {
self.to_be_bytes()
}
fn from_bytes(bytes: &[u8; 8]) -> Self {
Self::from_be_bytes(*bytes)
}
}Required Methods§
Sourcefn from_bytes(bytes: &[u8; N]) -> Self
fn from_bytes(bytes: &[u8; N]) -> Self
Get a value from a sequence of bytes
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".