pub struct JsonCodec;Expand description
The default codec: serde_json text.
Values written by TypeScript’s default serializer decode as long as they
are valid JSON for the destination type. The TypeScript undefined
sentinel decodes as JSON null: an Option<T> destination reads it as
None, a destination that accepts null (such as serde_json::Value)
decodes it, and any other destination fails open to the source.
Implementations§
Source§impl JsonCodec
impl JsonCodec
Sourcepub fn encode_value<T: Serialize>(value: &T) -> Result<Payload, BoxError>
pub fn encode_value<T: Serialize>(value: &T) -> Result<Payload, BoxError>
Serialize any Serialize value as compact JSON text.
Sourcepub fn decode_value<T: DeserializeOwned>(
payload: &Payload,
) -> Result<T, BoxError>
pub fn decode_value<T: DeserializeOwned>( payload: &Payload, ) -> Result<T, BoxError>
Deserialize JSON text, reading the TypeScript undefined sentinel as
JSON null.
Trait Implementations§
Source§impl<T: Serialize + DeserializeOwned + Send + Sync + 'static> Codec<T> for JsonCodec
impl<T: Serialize + DeserializeOwned + Send + Sync + 'static> Codec<T> for JsonCodec
Source§fn encode<'a>(
&'a self,
value: &'a T,
) -> BoxFuture<'a, Result<Payload, BoxError>>
fn encode<'a>( &'a self, value: &'a T, ) -> BoxFuture<'a, Result<Payload, BoxError>>
Serialize
value. A failure counts as a serialization_dump error
and skips the remote write.impl Copy for JsonCodec
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