Struct asynchronous_codec::CborCodec
source · pub struct CborCodec<Enc, Dec> { /* private fields */ }
Expand description
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§
Trait Implementations§
source§impl<Enc, Dec> Clone for CborCodec<Enc, Dec>where
for<'de> Dec: Deserialize<'de> + 'static,
for<'de> Enc: Serialize + 'static,
impl<Enc, Dec> Clone for CborCodec<Enc, Dec>where for<'de> Dec: Deserialize<'de> + 'static, for<'de> Enc: Serialize + 'static,
source§impl<Enc, Dec> Decoder for CborCodec<Enc, Dec>where
for<'de> Dec: Deserialize<'de> + 'static,
for<'de> Enc: Serialize + 'static,
impl<Enc, Dec> Decoder for CborCodec<Enc, Dec>where for<'de> Dec: Deserialize<'de> + 'static, for<'de> Enc: Serialize + 'static,
Decoder impl parses cbor objects from bytes
source§impl<Enc, Dec> Default for CborCodec<Enc, Dec>where
for<'de> Dec: Deserialize<'de> + 'static,
for<'de> Enc: Serialize + 'static,
impl<Enc, Dec> Default for CborCodec<Enc, Dec>where for<'de> Dec: Deserialize<'de> + 'static, for<'de> Enc: Serialize + 'static,
source§impl<Enc, Dec> Encoder for CborCodec<Enc, Dec>where
for<'de> Dec: Deserialize<'de> + 'static,
for<'de> Enc: Serialize + 'static,
impl<Enc, Dec> Encoder for CborCodec<Enc, Dec>where for<'de> Dec: Deserialize<'de> + 'static, for<'de> Enc: Serialize + 'static,
Encoder impl encodes object streams to bytes
source§impl<Enc: PartialEq, Dec: PartialEq> PartialEq<CborCodec<Enc, Dec>> for CborCodec<Enc, Dec>
impl<Enc: PartialEq, Dec: PartialEq> PartialEq<CborCodec<Enc, Dec>> for CborCodec<Enc, Dec>
impl<Enc, Dec> StructuralPartialEq for CborCodec<Enc, Dec>
Auto Trait Implementations§
impl<Enc, Dec> RefUnwindSafe for CborCodec<Enc, Dec>where Dec: RefUnwindSafe, Enc: RefUnwindSafe,
impl<Enc, Dec> Send for CborCodec<Enc, Dec>where Dec: Send, Enc: Send,
impl<Enc, Dec> Sync for CborCodec<Enc, Dec>where Dec: Sync, Enc: Sync,
impl<Enc, Dec> Unpin for CborCodec<Enc, Dec>where Dec: Unpin, Enc: Unpin,
impl<Enc, Dec> UnwindSafe for CborCodec<Enc, Dec>where Dec: UnwindSafe, Enc: UnwindSafe,
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