Enum Content

Source
enum Content<'de, 'a> {
    Input(&'de str),
    Slice(&'a str),
    Owned(String, usize),
}
Expand description

A version of Cow that can borrow from two different buffers, one of them is a deserializer input, and conceptually contains only part of owned data.

§Lifetimes

  • 'de – lifetime of the data that deserializer borrow from the parsed input
  • 'a – lifetime of the data that owned by a deserializer

Variants§

§

Input(&'de str)

An input borrowed from the parsed data

§

Slice(&'a str)

An input borrowed from the buffer owned by another deserializer

§

Owned(String, usize)

An input taken from an external deserializer, owned by that deserializer. Only part of this data, located after offset represented by usize, used to deserialize data, the other is a garbage that can’t be dropped because we do not want to make reallocations if they will not required.

Implementations§

Source§

impl<'de, 'a> Content<'de, 'a>

Source

fn as_str(&self) -> &str

Returns string representation of the content

Source

fn deserialize_all<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Supply to the visitor a borrowed string, a string slice, or an owned string depending on the kind of input. Unlike Self::deserialize_item, the whole Self::Owned string will be passed to the visitor.

Calls

  • visitor.visit_borrowed_str if data borrowed from the input
  • visitor.visit_str if data borrowed from another source
  • visitor.visit_string if data owned by this type
Source

fn deserialize_item<V>(self, visitor: V) -> Result<V::Value, DeError>
where V: Visitor<'de>,

Supply to the visitor a borrowed string, a string slice, or an owned string depending on the kind of input. Unlike Self::deserialize_all, only part of Self::Owned string will be passed to the visitor.

Calls

  • visitor.visit_borrowed_str if data borrowed from the input
  • visitor.visit_str if data borrowed from another source
  • visitor.visit_string if data owned by this type

Auto Trait Implementations§

§

impl<'de, 'a> Freeze for Content<'de, 'a>

§

impl<'de, 'a> RefUnwindSafe for Content<'de, 'a>

§

impl<'de, 'a> Send for Content<'de, 'a>

§

impl<'de, 'a> Sync for Content<'de, 'a>

§

impl<'de, 'a> Unpin for Content<'de, 'a>

§

impl<'de, 'a> UnwindSafe for Content<'de, 'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.