Struct Impossible

struct Impossible<Ok, Error> { ... }

Helper type for implementing a Serializer that does not support serializing one of the compound types.

This type cannot be instantiated, but implements every one of the traits corresponding to the Serializer compound types: SerializeSeq, SerializeTuple, SerializeTupleStruct, SerializeTupleVariant, SerializeMap, SerializeStruct, and SerializeStructVariant.

# use serde::ser::{Serializer, Impossible};
# use serde_core::__private::doc::Error;
#
# struct MySerializer;
#
impl Serializer for MySerializer {
    type Ok = ();
    type Error = Error;

    type SerializeSeq = Impossible<(), Error>;
    /* other associated types */

    /// This data format does not support serializing sequences.
    fn serialize_seq(self,
                     len: Option<usize>)
                     -> Result<Self::SerializeSeq, Error> {
        // Given Impossible cannot be instantiated, the only
        // thing we can do here is to return an error.
#         stringify! {
        Err(...)
#         };
#         unimplemented!()
    }

    /* other Serializer methods */
#     serde_core::__serialize_unimplemented! {
#         bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str bytes none some
#         unit unit_struct unit_variant newtype_struct newtype_variant
#         tuple tuple_struct tuple_variant map struct struct_variant
#     }
}

Implementations

impl<Ok, Error> Freeze for Impossible<Ok, Error>

impl<Ok, Error> RefUnwindSafe for Impossible<Ok, Error>

impl<Ok, Error> Send for Impossible<Ok, Error>

impl<Ok, Error> SerializeMap for Impossible<Ok, Error>

fn serialize_key<T>(self: &mut Self, key: &T) -> Result<(), Error>
where
    T: ?Sized + Serialize
fn serialize_value<T>(self: &mut Self, value: &T) -> Result<(), Error>
where
    T: ?Sized + Serialize
fn end(self: Self) -> Result<Ok, Error>

impl<Ok, Error> SerializeSeq for Impossible<Ok, Error>

fn serialize_element<T>(self: &mut Self, value: &T) -> Result<(), Error>
where
    T: ?Sized + Serialize
fn end(self: Self) -> Result<Ok, Error>

impl<Ok, Error> SerializeStruct for Impossible<Ok, Error>

fn serialize_field<T>(self: &mut Self, key: &'static str, value: &T) -> Result<(), Error>
where
    T: ?Sized + Serialize
fn end(self: Self) -> Result<Ok, Error>

impl<Ok, Error> SerializeStructVariant for Impossible<Ok, Error>

fn serialize_field<T>(self: &mut Self, key: &'static str, value: &T) -> Result<(), Error>
where
    T: ?Sized + Serialize
fn end(self: Self) -> Result<Ok, Error>

impl<Ok, Error> SerializeTuple for Impossible<Ok, Error>

fn serialize_element<T>(self: &mut Self, value: &T) -> Result<(), Error>
where
    T: ?Sized + Serialize
fn end(self: Self) -> Result<Ok, Error>

impl<Ok, Error> SerializeTupleStruct for Impossible<Ok, Error>

fn serialize_field<T>(self: &mut Self, value: &T) -> Result<(), Error>
where
    T: ?Sized + Serialize
fn end(self: Self) -> Result<Ok, Error>

impl<Ok, Error> SerializeTupleVariant for Impossible<Ok, Error>

fn serialize_field<T>(self: &mut Self, value: &T) -> Result<(), Error>
where
    T: ?Sized + Serialize
fn end(self: Self) -> Result<Ok, Error>

impl<Ok, Error> Sync for Impossible<Ok, Error>

impl<Ok, Error> Unpin for Impossible<Ok, Error>

impl<Ok, Error> UnsafeUnpin for Impossible<Ok, Error>

impl<Ok, Error> UnwindSafe for Impossible<Ok, Error>

impl<T> Any for Impossible<Ok, Error>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Impossible<Ok, Error>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Impossible<Ok, Error>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for Impossible<Ok, Error>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for Impossible<Ok, Error>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Impossible<Ok, Error>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Impossible<Ok, Error>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>