pub struct JsonBytesValueCodec<T> { /* private fields */ }Expand description
Encodes and decodes one serializable value through UTF-8 JSON bytes.
This type combines JsonBytesValueEncoder and JsonBytesValueDecoder
for registry-backed or bidirectional call sites. It holds no state between
calls, so it is Copy and Default, and encoding and decoding can share
one value through ValueEncoder and ValueDecoder.
§Type Parameters
T: Value type serialized to JSON bytes and recovered from them.
§Examples
use qubit_codec::JsonBytesValueCodec;
use qubit_codec::ValueDecoder;
use qubit_codec::ValueEncoder;
let mut codec = JsonBytesValueCodec::<String>::new();
assert_eq!(codec.encode(&"hello".to_string()).unwrap(), br#""hello""#.to_vec());
assert_eq!(codec.decode(br#""hello""#).unwrap(), "hello");Implementations§
Trait Implementations§
Source§impl<T: Clone> Clone for JsonBytesValueCodec<T>
impl<T: Clone> Clone for JsonBytesValueCodec<T>
impl<T: Copy> Copy for JsonBytesValueCodec<T>
Source§impl<T: Debug> Debug for JsonBytesValueCodec<T>
impl<T: Debug> Debug for JsonBytesValueCodec<T>
Source§impl<T: Default> Default for JsonBytesValueCodec<T>
impl<T: Default> Default for JsonBytesValueCodec<T>
Source§impl<T> ValueDecoder<[u8]> for JsonBytesValueCodec<T>where
T: DeserializeOwned,
impl<T> ValueDecoder<[u8]> for JsonBytesValueCodec<T>where
T: DeserializeOwned,
Source§impl<T> ValueEncoder<T> for JsonBytesValueCodec<T>where
T: Serialize,
impl<T> ValueEncoder<T> for JsonBytesValueCodec<T>where
T: Serialize,
Auto Trait Implementations§
impl<T> Freeze for JsonBytesValueCodec<T>where
PhantomData<T>: Freeze,
impl<T> RefUnwindSafe for JsonBytesValueCodec<T>where
PhantomData<T>: RefUnwindSafe,
impl<T> Send for JsonBytesValueCodec<T>where
PhantomData<T>: Send,
impl<T> Sync for JsonBytesValueCodec<T>where
PhantomData<T>: Sync,
impl<T> Unpin for JsonBytesValueCodec<T>where
PhantomData<T>: Unpin,
impl<T> UnsafeUnpin for JsonBytesValueCodec<T>where
PhantomData<T>: UnsafeUnpin,
impl<T> UnwindSafe for JsonBytesValueCodec<T>where
PhantomData<T>: 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