pub struct JsonSerializer;Available on crate feature
json only.Expand description
The default Serializer: JSON via serde_json. Ships behind the default json
feature; disable it to supply a different wire format (ADR 0010).
use reliar_core::{JsonSerializer, Serializer};
#[derive(serde::Serialize, serde::Deserialize)]
struct Ping;
impl reliar_core::Message for Ping {
const TYPE: &'static str = "ping";
const VERSION: u16 = 1;
}
let serializer = JsonSerializer;
let bytes = serializer.serialize(&Ping)?;
let _: Ping = serializer.deserialize(&bytes)?;
assert_eq!(serializer.content_type().as_str(), "application/json");Trait Implementations§
Source§impl Clone for JsonSerializer
impl Clone for JsonSerializer
Source§fn clone(&self) -> JsonSerializer
fn clone(&self) -> JsonSerializer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for JsonSerializer
impl Debug for JsonSerializer
Source§impl Default for JsonSerializer
impl Default for JsonSerializer
Source§fn default() -> JsonSerializer
fn default() -> JsonSerializer
Returns the “default value” for a type. Read more
Source§impl Serializer for JsonSerializer
impl Serializer for JsonSerializer
Source§fn content_type(&self) -> &ContentType
fn content_type(&self) -> &ContentType
The content type this serializer produces. Populates both
DeliveryMetadata::content_type and a
provider’s content_type column — one value, chosen by the serializer, never by the
call site. Read moreSource§fn serialize<T>(
&self,
body: &T,
) -> Result<Bytes, <JsonSerializer as Serializer>::Error>where
T: Message,
fn serialize<T>(
&self,
body: &T,
) -> Result<Bytes, <JsonSerializer as Serializer>::Error>where
T: Message,
Serializes a message body to bytes. Read more
Source§fn deserialize<T>(
&self,
bytes: &[u8],
) -> Result<T, <JsonSerializer as Serializer>::Error>where
T: Message,
fn deserialize<T>(
&self,
bytes: &[u8],
) -> Result<T, <JsonSerializer as Serializer>::Error>where
T: Message,
Deserializes bytes back into a message body. Read more
Auto Trait Implementations§
impl Freeze for JsonSerializer
impl RefUnwindSafe for JsonSerializer
impl Send for JsonSerializer
impl Sync for JsonSerializer
impl Unpin for JsonSerializer
impl UnsafeUnpin for JsonSerializer
impl UnwindSafe for JsonSerializer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more