Struct serde_buf::Ref

source ·
pub struct Ref<'a>(_);
Expand description

A partly owned value.

This buffer allows strings to be borrowed internally.

Implementations§

source§

impl Ref<'static>

source

pub fn buffer(v: impl Serialize) -> Result<Self, Error>

Buffer v into an owned buffer.

The resulting buffer is guaranteed to serialize to the same value as v.

source§

impl<'a> Ref<'a>

source

pub fn unit() -> Self

Create a buffer for a () value.

source

pub fn bool(v: bool) -> Self

Create a buffer for a boolean value.

source

pub fn u8(v: u8) -> Self

Create a buffer for an unsigned integer value.

source

pub fn u16(v: u16) -> Self

Create a buffer for an unsigned integer value.

source

pub fn u32(v: u32) -> Self

Create a buffer for an unsigned integer value.

source

pub fn u64(v: u64) -> Self

Create a buffer for an unsigned integer value.

source

pub fn u128(v: u128) -> Self

Create a buffer for an unsigned integer value.

source

pub fn i8(v: i8) -> Self

Create a buffer for a signed integer value.

source

pub fn i16(v: i16) -> Self

Create a buffer for a signed integer value.

source

pub fn i32(v: i32) -> Self

Create a buffer for a signed integer value.

source

pub fn i64(v: i64) -> Self

Create a buffer for a signed integer value.

source

pub fn i128(v: i128) -> Self

Create a buffer for a signed integer value.

source

pub fn f32(v: f32) -> Self

Create a buffer for a binary floating point value.

source

pub fn f64(v: f64) -> Self

Create a buffer for a binary floating point value.

source

pub fn char(v: char) -> Self

Create a buffer for a single character value.

source

pub fn owned_str(v: impl Into<String>) -> Self

Create a buffer for an owned string value.

source

pub fn str(v: &'a impl Borrow<str> + ?Sized) -> Self

Create a buffer for a borrowed string value.

source

pub fn owned_bytes(v: impl Into<Vec<u8>>) -> Self

Create a buffer for an owned byte-string value.

source

pub fn bytes(v: &'a impl Borrow<[u8]> + ?Sized) -> Self

Create a buffer for a borrowed byte-string value.

source

pub fn none() -> Self

Create a buffer for an Option::None value.

source

pub fn some(v: impl Into<Ref<'a>>) -> Self

Create a buffer for an Option::Some value.

source

pub fn unit_struct(name: &'static str) -> Self

Create a buffer for a unit struct, like struct A.

source

pub fn newtype_struct(name: &'static str, value: impl Into<Ref<'a>>) -> Self

Create a buffer for a newtype struct, like struct A(T).

source

pub fn record_struct( name: &'static str, fields: impl IntoIterator<Item = (&'static str, Ref<'a>)> ) -> Self

Create a buffer for a struct with named fields, like struct A { a: T, b: U }.

source

pub fn tuple_struct( name: &'static str, fields: impl IntoIterator<Item = Ref<'a>> ) -> Self

Create a buffer for a struct with unnamed fields, like struct A(T, U).

source

pub fn tuple(fields: impl IntoIterator<Item = Ref<'a>>) -> Self

Create a buffer for a tuple, like (T, U).

source

pub fn unit_variant( name: &'static str, variant_index: u32, variant: &'static str ) -> Self

Create a buffer for a unit enum variant, like A::B.

source

pub fn newtype_variant( name: &'static str, variant_index: u32, variant: &'static str, value: impl Into<Ref<'a>> ) -> Self

Create a buffer for a newtype enum variant, like A::B(T).

source

pub fn tuple_variant( name: &'static str, variant_index: u32, variant: &'static str, fields: impl IntoIterator<Item = Ref<'a>> ) -> Self

Create a buffer for an enum variant with unnamed fields, like A::B(T, U).

source

pub fn record_struct_variant( name: &'static str, variant_index: u32, variant: &'static str, fields: impl IntoIterator<Item = (&'static str, Ref<'a>)> ) -> Self

Create a buffer for an enum variant with named fields, like A::B { a: T, b: U }.

source

pub fn seq(fields: impl IntoIterator<Item = Ref<'a>>) -> Self

Create a buffer for a sequence.

source

pub fn map(fields: impl IntoIterator<Item = (Ref<'a>, Ref<'a>)>) -> Self

Create a buffer for a map.

Trait Implementations§

source§

impl<'a> Clone for Ref<'a>

source§

fn clone(&self) -> Ref<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for Ref<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Owned> for Ref<'static>

source§

fn from(value: Owned) -> Self

Converts to this type from the input type.
source§

impl From<Ref<'static>> for Owned

source§

fn from(value: Ref<'static>) -> Self

Converts to this type from the input type.
source§

impl<'de> IntoDeserializer<'de, Error> for Ref<'de>

§

type Deserializer = Deserializer<'de>

The type of the deserializer being converted into.
source§

fn into_deserializer(self) -> Self::Deserializer

Convert this value into a deserializer.
source§

impl<'a> Serialize for Ref<'a>

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Ref<'a>

§

impl<'a> Send for Ref<'a>

§

impl<'a> Sync for Ref<'a>

§

impl<'a> Unpin for Ref<'a>

§

impl<'a> UnwindSafe for Ref<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.