pub trait SerializeWithContext<C>: Sized {
// Required method
fn serialize_with_context<S>(
&self,
serializer: S,
context: &C,
) -> Result<S::Ok, S::Error>
where S: Serializer;
// Provided method
fn serialize_fields_with_context<S>(
&self,
serializer: S,
context: &C,
_fields: &HashSet<String>,
) -> Result<S::Ok, S::Error>
where S: Serializer { ... }
}
Expand description
Similar to Serialize
, but takes an extra context
argument and
threads it through all nested structures.
Required Methods§
fn serialize_with_context<S>(
&self,
serializer: S,
context: &C,
) -> Result<S::Ok, S::Error>where
S: Serializer,
Provided Methods§
fn serialize_fields_with_context<S>(
&self,
serializer: S,
context: &C,
_fields: &HashSet<String>,
) -> Result<S::Ok, S::Error>where
S: Serializer,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.