[−][src]Struct asynchronous_codec::CborCodec
A codec for JSON encoding and decoding using serde_cbor Enc is the type to encode, Dec is the type to decode
use serde::{Serialize, Deserialize}; use asynchronous_codec::{CborCodec, Framed}; #[derive(Serialize, Deserialize)] struct Something { pub data: u16, } async move { // let stream = ... let codec = CborCodec::<Something, Something>::new(); let mut framed = Framed::new(stream, codec); while let Some(s) = framed.try_next().await.unwrap() { println!("{:?}", s.data); } };
Implementations
impl<Enc, Dec> CborCodec<Enc, Dec> where
Dec: Deserialize<'de> + 'static,
Enc: Serialize + 'static,
[src]
Dec: Deserialize<'de> + 'static,
Enc: Serialize + 'static,
Trait Implementations
impl<Enc, Dec> Clone for CborCodec<Enc, Dec> where
Dec: Deserialize<'de> + 'static,
Enc: Serialize + 'static,
[src]
Dec: Deserialize<'de> + 'static,
Enc: Serialize + 'static,
pub fn clone(&self) -> CborCodec<Enc, Dec>
[src]
Clone creates a new instance of the CborCodec
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<Enc: Debug, Dec: Debug> Debug for CborCodec<Enc, Dec>
[src]
impl<Enc, Dec> Decoder for CborCodec<Enc, Dec> where
Dec: Deserialize<'de> + 'static,
Enc: Serialize + 'static,
[src]
Dec: Deserialize<'de> + 'static,
Enc: Serialize + 'static,
Decoder impl parses cbor objects from bytes
type Item = Dec
The type of items returned by decode
type Error = CborCodecError
The type of decoding errors.
pub fn decode(
&mut self,
buf: &mut BytesMut
) -> Result<Option<Self::Item>, Self::Error>
[src]
&mut self,
buf: &mut BytesMut
) -> Result<Option<Self::Item>, Self::Error>
pub fn decode_eof(
&mut self,
src: &mut BytesMut
) -> Result<Option<Self::Item>, Self::Error>
[src]
&mut self,
src: &mut BytesMut
) -> Result<Option<Self::Item>, Self::Error>
impl<Enc, Dec> Default for CborCodec<Enc, Dec> where
Dec: Deserialize<'de> + 'static,
Enc: Serialize + 'static,
[src]
Dec: Deserialize<'de> + 'static,
Enc: Serialize + 'static,
impl<Enc, Dec> Encoder for CborCodec<Enc, Dec> where
Dec: Deserialize<'de> + 'static,
Enc: Serialize + 'static,
[src]
Dec: Deserialize<'de> + 'static,
Enc: Serialize + 'static,
Encoder impl encodes object streams to bytes
type Item = Enc
The type of items consumed by encode
type Error = CborCodecError
The type of encoding errors.
pub fn encode(
&mut self,
data: Self::Item,
buf: &mut BytesMut
) -> Result<(), Self::Error>
[src]
&mut self,
data: Self::Item,
buf: &mut BytesMut
) -> Result<(), Self::Error>
impl<Enc: PartialEq, Dec: PartialEq> PartialEq<CborCodec<Enc, Dec>> for CborCodec<Enc, Dec>
[src]
pub fn eq(&self, other: &CborCodec<Enc, Dec>) -> bool
[src]
pub fn ne(&self, other: &CborCodec<Enc, Dec>) -> bool
[src]
impl<Enc, Dec> StructuralPartialEq for CborCodec<Enc, Dec>
[src]
Auto Trait Implementations
impl<Enc, Dec> RefUnwindSafe for CborCodec<Enc, Dec> where
Dec: RefUnwindSafe,
Enc: RefUnwindSafe,
[src]
Dec: RefUnwindSafe,
Enc: RefUnwindSafe,
impl<Enc, Dec> Send for CborCodec<Enc, Dec> where
Dec: Send,
Enc: Send,
[src]
Dec: Send,
Enc: Send,
impl<Enc, Dec> Sync for CborCodec<Enc, Dec> where
Dec: Sync,
Enc: Sync,
[src]
Dec: Sync,
Enc: Sync,
impl<Enc, Dec> Unpin for CborCodec<Enc, Dec> where
Dec: Unpin,
Enc: Unpin,
[src]
Dec: Unpin,
Enc: Unpin,
impl<Enc, Dec> UnwindSafe for CborCodec<Enc, Dec> where
Dec: UnwindSafe,
Enc: UnwindSafe,
[src]
Dec: UnwindSafe,
Enc: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,