pub struct JsonCodec { /* private fields */ }Expand description
JSON codec implementation using serde_json
Implementations§
Source§impl JsonCodec
impl JsonCodec
Sourcepub fn encode_string<T>(&self, value: &T) -> Result<String, CodecError>where
T: Serialize,
pub fn encode_string<T>(&self, value: &T) -> Result<String, CodecError>where
T: Serialize,
Encode a value directly to a JSON string
Sourcepub fn decode_str<T>(&self, data: &str) -> Result<T, CodecError>where
T: DeserializeOwned,
pub fn decode_str<T>(&self, data: &str) -> Result<T, CodecError>where
T: DeserializeOwned,
Decode a JSON string to a value
Trait Implementations§
Source§impl Codec for JsonCodec
impl Codec for JsonCodec
Source§fn encode<T>(&self, value: &T) -> Result<Vec<u8>, CodecError>where
T: Serialize,
fn encode<T>(&self, value: &T) -> Result<Vec<u8>, CodecError>where
T: Serialize,
Encode a value to bytes
Source§fn decode<T>(&self, data: &[u8]) -> Result<T, CodecError>where
T: DeserializeOwned,
fn decode<T>(&self, data: &[u8]) -> Result<T, CodecError>where
T: DeserializeOwned,
Decode bytes to a value
Source§fn content_type(&self) -> &'static str
fn content_type(&self) -> &'static str
Get the content type for this codec
Auto Trait Implementations§
impl Freeze for JsonCodec
impl RefUnwindSafe for JsonCodec
impl Send for JsonCodec
impl Sync for JsonCodec
impl Unpin for JsonCodec
impl UnsafeUnpin for JsonCodec
impl UnwindSafe for JsonCodec
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