Clarify the role of Impossible serializer
This commit is contained in:
parent
d4bb687032
commit
81f28da8e1
@ -14,16 +14,23 @@ use ser::{
|
|||||||
SerializeStructVariant,
|
SerializeStructVariant,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The impossible serializer.
|
/// Helper type for implementing a `Serializer` that does not support
|
||||||
|
/// serializing one of the compound types.
|
||||||
///
|
///
|
||||||
/// This serializer cannot be instantiated, to be used in the associated types
|
/// This type cannot be instantiated, but implements every one of the traits
|
||||||
/// of the `Serializer` trait, when implementing serializers that don't support
|
/// corresponding to the `Serializer` compound types: `SerializeSeq`,
|
||||||
/// some constructs, like sequences or tuples.
|
/// `SerializeTuple`, `SerializeTupleStruct`, `SerializeTupleVariant`,
|
||||||
|
/// `SerializeMap`, `SerializeStruct`, and `SerializeStructVariant`.
|
||||||
///
|
///
|
||||||
/// ```rust,ignore
|
/// ```rust,ignore
|
||||||
/// impl Serializer for MySerializer {
|
/// impl Serializer for MySerializer {
|
||||||
/// type SerializeSeq = Impossible<(), Error>;
|
/// type Ok = ();
|
||||||
|
/// type Error = Error;
|
||||||
///
|
///
|
||||||
|
/// type SerializeSeq = Impossible<(), Error>;
|
||||||
|
/// /* other associated types */
|
||||||
|
///
|
||||||
|
/// /// This data format does not support serializing sequences.
|
||||||
/// fn serialize_seq(self,
|
/// fn serialize_seq(self,
|
||||||
/// len: Option<usize>)
|
/// len: Option<usize>)
|
||||||
/// -> Result<Self::SerializeSeq, Error> {
|
/// -> Result<Self::SerializeSeq, Error> {
|
||||||
@ -32,7 +39,7 @@ use ser::{
|
|||||||
/// Err(...)
|
/// Err(...)
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// ...
|
/// /* other Serializer methods */
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub struct Impossible<Ok, E> {
|
pub struct Impossible<Ok, E> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user