pub struct JsonSerializer { /* private fields */ }Expand description
JSON serializer with configurable formatting options.
Implementations§
Source§impl JsonSerializer
impl JsonSerializer
Sourcepub fn with_options(options: SerializeOptions) -> Self
pub fn with_options(options: SerializeOptions) -> Self
Create a new JSON serializer with the given options.
Trait Implementations§
Source§impl Default for JsonSerializer
impl Default for JsonSerializer
Source§impl FormatSerializer for JsonSerializer
impl FormatSerializer for JsonSerializer
Source§type Error = JsonSerializeError
type Error = JsonSerializeError
Format-specific error type.
Source§fn field_key(&mut self, key: &str) -> Result<(), Self::Error>
fn field_key(&mut self, key: &str) -> Result<(), Self::Error>
Emit a field key within a struct.
Source§fn raw_serialize_shape(&self) -> Option<&'static Shape>
fn raw_serialize_shape(&self) -> Option<&'static Shape>
Returns the shape of the format’s raw capture type for serialization. Read more
Source§fn raw_scalar(&mut self, content: &str) -> Result<(), Self::Error>
fn raw_scalar(&mut self, content: &str) -> Result<(), Self::Error>
Emit a raw scalar value (for RawJson, etc.) without any encoding/escaping. Read more
Source§fn field_metadata(&mut self, _field: &FieldItem) -> Result<(), Self::Error>
fn field_metadata(&mut self, _field: &FieldItem) -> Result<(), Self::Error>
Optional: Provide field metadata before field_key is called.
This allows formats like XML to extract namespace information.
Default implementation does nothing.
Source§fn struct_metadata(&mut self, _shape: &Shape) -> Result<(), Self::Error>
fn struct_metadata(&mut self, _shape: &Shape) -> Result<(), Self::Error>
Optional: Provide struct/enum type metadata when beginning to serialize it.
This allows formats to extract container-level attributes like xml::ns_all.
Default implementation does nothing.
Source§fn variant_metadata(
&mut self,
_variant: &'static Variant,
) -> Result<(), Self::Error>
fn variant_metadata( &mut self, _variant: &'static Variant, ) -> Result<(), Self::Error>
Optional: Provide variant metadata before serializing an enum variant.
This allows formats like XML to use the variant name as the element name
for xml::elements serialization.
Default implementation does nothing.
Source§fn preferred_field_order(&self) -> FieldOrdering
fn preferred_field_order(&self) -> FieldOrdering
Preferred field ordering for this format.
Formats like XML can request attributes-first ordering to avoid buffering.
Default is declaration order.
Source§fn begin_seq_with_len(&mut self, _len: usize) -> Result<(), Self::Error>
fn begin_seq_with_len(&mut self, _len: usize) -> Result<(), Self::Error>
Begin a sequence with known length. Read more
Source§fn typed_scalar(
&mut self,
scalar_type: ScalarType,
value: Peek<'_, '_>,
) -> Result<(), Self::Error>
fn typed_scalar( &mut self, scalar_type: ScalarType, value: Peek<'_, '_>, ) -> Result<(), Self::Error>
Serialize a scalar with full type information. 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 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