pub struct Decoder<'buf>(/* private fields */);Expand description
Implementations§
Source§impl<'buf> Decoder<'buf>
impl<'buf> Decoder<'buf>
Sourcepub fn decode<D>(&mut self) -> Option<D>where
D: Decode<'buf>,
pub fn decode<D>(&mut self) -> Option<D>where
D: Decode<'buf>,
Decodes a value from the buffer.
Sourcepub fn decode_with<D>(&mut self, state: D::State) -> Option<D>where
D: DecodeWith<'buf>,
pub fn decode_with<D>(&mut self, state: D::State) -> Option<D>where
D: DecodeWith<'buf>,
Decodes a value from the buffer with passed state.
Sourcepub fn u8(&mut self) -> Option<u8>
pub fn u8(&mut self) -> Option<u8>
Decodes an u8 value.
§Examples
use co::AsDecoder;
let mut dec = [3].as_decoder();
let n = dec.u8()?;
assert_eq!(n, 3);Sourcepub fn u16(&mut self) -> Option<u16>
pub fn u16(&mut self) -> Option<u16>
Decodes an u16 value with big-endian byte ordering.
§Examples
use co::AsDecoder;
let mut dec = [0, 3].as_decoder();
let n = dec.u16()?;
assert_eq!(n, 3);Sourcepub fn u32(&mut self) -> Option<u32>
pub fn u32(&mut self) -> Option<u32>
Decodes an u32 value with big-endian byte ordering.
§Examples
use co::AsDecoder;
let mut dec = [0, 0, 0, 3].as_decoder();
let n = dec.u32()?;
assert_eq!(n, 3);Sourcepub fn u64(&mut self) -> Option<u64>
pub fn u64(&mut self) -> Option<u64>
Decodes an u64 value with big-endian byte ordering.
§Examples
use co::AsDecoder;
let mut dec = [0, 0, 0, 0, 0, 0, 0, 3].as_decoder();
let n = dec.u64()?;
assert_eq!(n, 3);Sourcepub fn u128(&mut self) -> Option<u128>
pub fn u128(&mut self) -> Option<u128>
Decodes an u128 value with big-endian byte ordering.
§Examples
use co::AsDecoder;
let mut dec = [
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 3,
].as_decoder();
let n = dec.u128()?;
assert_eq!(n, 3);Auto Trait Implementations§
impl<'buf> Freeze for Decoder<'buf>
impl<'buf> RefUnwindSafe for Decoder<'buf>
impl<'buf> Send for Decoder<'buf>
impl<'buf> Sync for Decoder<'buf>
impl<'buf> Unpin for Decoder<'buf>
impl<'buf> UnwindSafe for Decoder<'buf>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more