Trait recode::Decoder

source ·
pub trait Decoder<Item = Self> {
    type Error;

    // Required method
    fn decode(buf: &mut BytesMut) -> Result<Item, Self::Error>;

    // Provided method
    fn has_enough_bytes(_buf: &BytesMut) -> bool { ... }
}
Expand description

A trait for types that can decode values of type [Decoder::Output] from a bytes buffer of type Bytes.

Required Associated Types§

source

type Error

The type of error that can occur if decoding fails.

Required Methods§

source

fn decode(buf: &mut BytesMut) -> Result<Item, Self::Error>

Decodes a value from the given buffer.

Arguments
  • buf - The buffer to decode the value from.
Returns

The decoded value.

Provided Methods§

source

fn has_enough_bytes(_buf: &BytesMut) -> bool

Returns true if the given buffer can be decoded.

This is used to determine if the buffer has enough bytes to decode a value.

Implementations on Foreign Types§

source§

impl Decoder<usize> for u64

source§

impl Decoder<usize> for i8

source§

impl Decoder<u16> for u16

§

type Error = Error

source§

fn decode(buf: &mut BytesMut) -> Result<Self, Self::Error>

source§

fn has_enough_bytes(buf: &BytesMut) -> bool

source§

impl Decoder<i32> for i32

§

type Error = Error

source§

fn decode(buf: &mut BytesMut) -> Result<Self, Self::Error>

source§

fn has_enough_bytes(buf: &BytesMut) -> bool

source§

impl Decoder<usize> for u8

source§

impl Decoder<i16> for i16

§

type Error = Error

source§

fn decode(buf: &mut BytesMut) -> Result<Self, Self::Error>

source§

fn has_enough_bytes(buf: &BytesMut) -> bool

source§

impl Decoder<usize> for u16

source§

impl Decoder<u32> for u32

§

type Error = Error

source§

fn decode(buf: &mut BytesMut) -> Result<Self, Self::Error>

source§

fn has_enough_bytes(buf: &BytesMut) -> bool

source§

impl Decoder<u8> for u8

§

type Error = Error

source§

fn decode(buf: &mut BytesMut) -> Result<Self, Self::Error>

source§

fn has_enough_bytes(buf: &BytesMut) -> bool

source§

impl Decoder<usize> for u128

source§

impl Decoder<usize> for i128

source§

impl Decoder<u128> for u128

§

type Error = Error

source§

fn decode(buf: &mut BytesMut) -> Result<Self, Self::Error>

source§

fn has_enough_bytes(buf: &BytesMut) -> bool

source§

impl Decoder<usize> for i32

source§

impl Decoder<i8> for i8

§

type Error = Error

source§

fn decode(buf: &mut BytesMut) -> Result<Self, Self::Error>

source§

fn has_enough_bytes(buf: &BytesMut) -> bool

source§

impl Decoder<i128> for i128

§

type Error = Error

source§

fn decode(buf: &mut BytesMut) -> Result<Self, Self::Error>

source§

fn has_enough_bytes(buf: &BytesMut) -> bool

source§

impl Decoder<u64> for u64

§

type Error = Error

source§

fn decode(buf: &mut BytesMut) -> Result<Self, Self::Error>

source§

fn has_enough_bytes(buf: &BytesMut) -> bool

source§

impl Decoder<usize> for i64

source§

impl Decoder<usize> for i16

source§

impl Decoder<usize> for u32

source§

impl Decoder<i64> for i64

§

type Error = Error

source§

fn decode(buf: &mut BytesMut) -> Result<Self, Self::Error>

source§

fn has_enough_bytes(buf: &BytesMut) -> bool

Implementors§