pub trait VariantEncoder: Sized {
type Cx: Context<Error = Self::Error>;
type Error;
type Mode: 'static;
type EncodeTag<'this>: Encoder<Cx = Self::Cx, Error = Self::Error, Mode = Self::Mode>
where Self: 'this;
type EncodeData<'this>: Encoder<Cx = Self::Cx, Error = Self::Error, Mode = Self::Mode>
where Self: 'this;
// Required methods
fn cx(&self) -> Self::Cx;
fn encode_tag(&mut self) -> Result<Self::EncodeTag<'_>, Self::Error>;
fn encode_data(&mut self) -> Result<Self::EncodeData<'_>, Self::Error>;
fn finish_variant(self) -> Result<(), Self::Error>;
// Provided method
fn insert_variant<T, V>(self, tag: T, value: V) -> Result<(), Self::Error>
where T: Encode<Self::Mode>,
V: Encode<Self::Mode> { ... }
}Expand description
Trait governing how to encode a variant.
Required Associated Types§
Required Methods§
Sourcefn encode_tag(&mut self) -> Result<Self::EncodeTag<'_>, Self::Error>
fn encode_tag(&mut self) -> Result<Self::EncodeTag<'_>, Self::Error>
Return the encoder for the first element in the variant.
Sourcefn encode_data(&mut self) -> Result<Self::EncodeData<'_>, Self::Error>
fn encode_data(&mut self) -> Result<Self::EncodeData<'_>, Self::Error>
Return encoder for the second element in the variant.
Sourcefn finish_variant(self) -> Result<(), Self::Error>
fn finish_variant(self) -> Result<(), Self::Error>
End the variant encoder.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".