Trait rdkafka::message::FromBytes

source ·
pub trait FromBytes {
    type Error;

    // Required method
    fn from_bytes(_: &[u8]) -> Result<&Self, Self::Error>;
}
Expand description

A cheap conversion from a byte slice to typed data.

Given a reference to a byte slice, returns a different view of the same data. No allocation is performed, however the underlying data might be checked for correctness (for example when converting to str).

See also the ToBytes trait.

Required Associated Types§

source

type Error

The error type that will be returned if the conversion fails.

Required Methods§

source

fn from_bytes(_: &[u8]) -> Result<&Self, Self::Error>

Tries to convert the provided byte slice into a different type.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl FromBytes for str

§

type Error = Utf8Error

source§

fn from_bytes(bytes: &[u8]) -> Result<&Self, Self::Error>

source§

impl FromBytes for [u8]

§

type Error = ()

source§

fn from_bytes(bytes: &[u8]) -> Result<&Self, Self::Error>

Implementors§