[−][src]Struct framed::typed::Codec
Contains methods for encoding and decoding a serializable type T
with a specific configuration.
Construct an instance from a Config
instance with the
Config::to_codec
method.
Methods
impl<T: DeserializeOwned + Serialize> Codec<T>
[src]
pub fn encode_to_slice(
&mut self,
v: &T,
ser_buf: &mut TempBuffer,
dest: &mut Encoded
) -> Result<usize>
[src]
&mut self,
v: &T,
ser_buf: &mut TempBuffer,
dest: &mut Encoded
) -> Result<usize>
Serializes and encodes the supplied value v
into destination
buffer dest
, using ser_buf
as a temporary serialization buffer.
Available from no_std
crates.
Returns the number of bytes written to the beginning of dest
.
Panics
This will panic if the supplied buffers are too small to serialize
a value of T
. Callers must ensure that:
ser_buf.len() >= max_serialize_buf_len::<T>()
anddest.len() >= max_encoded_len::<T>()
.
Examples
See the no_std usage example
in the typed
module documentation.
pub fn decode_from_slice(
&mut self,
e: &Encoded,
de_buf: &mut TempBuffer
) -> Result<T>
[src]
&mut self,
e: &Encoded,
de_buf: &mut TempBuffer
) -> Result<T>
Decodes the supplied encoded frame e
, then deserializes its
payload as a value of type T
, using de_buf
as a temporary
deserialization buffer. Available from no_std
crates.
Returns the deserialized value.
Panics
This will panic if the supplied buffer is too small to deserialize
a value of T
. Callers must ensure that:
de_buf.len() >= max_serialize_buf_len::<T>()
.
Examples
See the no_std usage example
in the typed
module documentation.
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,