[−][src]Trait frombytes::FromBytes
Fallible conversion of bytes to a new type.
Examples
use frombytes::{Bytes, Error, FromBytes}; struct MyStruct { a: u32, b: i16, } impl FromBytes for MyStruct { // we simply use the same error that primitives use // but any error could be used type Error = Error; fn from_bytes(bytes: &mut Bytes) -> Result<Self, Self::Error> { // uses type inference to know to read a `u32` let a = bytes.read()?; // uses type inference to know to read a `i16` let b = bytes.read()?; Ok(Self { a, b }) } }
Associated Types
type Error
The associated error which can be returned from parsing.
All primitive types as well as radiotap fields implementing this trait
set this error to Error
.
Required methods
fn from_bytes(bytes: &mut Bytes<'_>) -> Result<Self, Self::Error>
Implementations on Foreign Types
impl FromBytes for u8
[src]
impl FromBytes for u16
[src]
impl FromBytes for u32
[src]
impl FromBytes for u64
[src]
impl FromBytes for u128
[src]
impl FromBytes for i8
[src]
impl FromBytes for i16
[src]
impl FromBytes for i32
[src]
impl FromBytes for i64
[src]
impl FromBytes for i128
[src]
impl<T, E> FromBytes for [T; 1] where
T: FromBytes<Error = E> + Default,
[src]
T: FromBytes<Error = E> + Default,
type Error = E
fn from_bytes(bytes: &mut Bytes<'_>) -> Result<Self, E>
[src]
impl<T, E> FromBytes for [T; 2] where
T: FromBytes<Error = E> + Default,
[src]
T: FromBytes<Error = E> + Default,
type Error = E
fn from_bytes(bytes: &mut Bytes<'_>) -> Result<Self, E>
[src]
impl<T, E> FromBytes for [T; 3] where
T: FromBytes<Error = E> + Default,
[src]
T: FromBytes<Error = E> + Default,
type Error = E
fn from_bytes(bytes: &mut Bytes<'_>) -> Result<Self, E>
[src]
impl<T, E> FromBytes for [T; 4] where
T: FromBytes<Error = E> + Default,
[src]
T: FromBytes<Error = E> + Default,