pub trait BElement<T>where
T: BElement<T>,{
// Required method
fn decode(encoded: &[u8]) -> Result<(usize, T), &'static str>;
}
Expand description
Trait for all bencode elements.
Provides way to decode some type of element T
, which must have trait BElement
, from
array of bytes
§Examples
Simple implementation.
use bencode_decoder::BElement;
struct BExample {
e: i8,
}
impl BElement<BExample> for BExample {
fn decode(encoded: &[u8]) -> Result<(usize, BExample), &'static str> {
Err("No implementation, sorry")
}
}
Required Methods§
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.