Struct rkyv::with::AsOwned

source ·
pub struct AsOwned;
Expand description

A wrapper that serializes a Cow as if it were owned.

Example

use std::borrow::Cow;
use rkyv::{Archive, with::AsOwned};

#[derive(Archive)]
struct Example<'a> {
    #[with(AsOwned)]
    a: Cow<'a, str>,
}

Trait Implementations§

source§

impl<'a, T: Archive + Clone> ArchiveWith<Cow<'a, [T]>> for AsOwned

§

type Archived = ArchivedVec<<T as Archive>::Archived>

The archived type of a With<F, Self>.
§

type Resolver = VecResolver

The resolver of a With<F, Self>.
source§

unsafe fn resolve_with( field: &Cow<'a, [T]>, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived )

Resolves the archived type using a reference to the field type F. Read more
source§

impl<'a> ArchiveWith<Cow<'a, CStr>> for AsOwned

§

type Archived = ArchivedCString

The archived type of a With<F, Self>.
§

type Resolver = CStringResolver

The resolver of a With<F, Self>.
source§

unsafe fn resolve_with( field: &Cow<'a, CStr>, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived )

Resolves the archived type using a reference to the field type F. Read more
source§

impl<'a, F: Archive + Clone> ArchiveWith<Cow<'a, F>> for AsOwned

§

type Archived = <F as Archive>::Archived

The archived type of a With<F, Self>.
§

type Resolver = <F as Archive>::Resolver

The resolver of a With<F, Self>.
source§

unsafe fn resolve_with( field: &Cow<'a, F>, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived )

Resolves the archived type using a reference to the field type F. Read more
source§

impl<'a> ArchiveWith<Cow<'a, str>> for AsOwned

§

type Archived = ArchivedString

The archived type of a With<F, Self>.
§

type Resolver = StringResolver

The resolver of a With<F, Self>.
source§

unsafe fn resolve_with( field: &Cow<'a, str>, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived )

Resolves the archived type using a reference to the field type F. Read more
source§

impl Debug for AsOwned

source§

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

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

impl<T: Archive + Clone, D: Fallible + ?Sized> DeserializeWith<<T as Archive>::Archived, T, D> for AsOwned
where T::Archived: Deserialize<T, D>,

source§

fn deserialize_with( field: &T::Archived, deserializer: &mut D ) -> Result<T, D::Error>

Deserializes the field type F using the given deserializer.
source§

impl<'a, D: Fallible + ?Sized> DeserializeWith<ArchivedCString, Cow<'a, CStr>, D> for AsOwned

source§

fn deserialize_with( field: &ArchivedCString, deserializer: &mut D ) -> Result<Cow<'a, CStr>, D::Error>

Deserializes the field type F using the given deserializer.
source§

impl<'a, D: Fallible + ?Sized> DeserializeWith<ArchivedString, Cow<'a, str>, D> for AsOwned

source§

fn deserialize_with( field: &ArchivedString, deserializer: &mut D ) -> Result<Cow<'a, str>, D::Error>

Deserializes the field type F using the given deserializer.
source§

impl<'a, T, D> DeserializeWith<ArchivedVec<<T as Archive>::Archived>, Cow<'a, [T]>, D> for AsOwned
where T: Archive + Clone, T::Archived: Deserialize<T, D>, D: Fallible + ?Sized,

source§

fn deserialize_with( field: &ArchivedVec<T::Archived>, deserializer: &mut D ) -> Result<Cow<'a, [T]>, D::Error>

Deserializes the field type F using the given deserializer.
source§

impl<'a, T: Serialize<S> + Clone, S: ScratchSpace + Serializer + ?Sized> SerializeWith<Cow<'a, [T]>, S> for AsOwned

source§

fn serialize_with( field: &Cow<'a, [T]>, serializer: &mut S ) -> Result<Self::Resolver, S::Error>

Serializes the field type F using the given serializer.
source§

impl<'a, S: Serializer + ?Sized> SerializeWith<Cow<'a, CStr>, S> for AsOwned

source§

fn serialize_with( field: &Cow<'a, CStr>, serializer: &mut S ) -> Result<Self::Resolver, S::Error>

Serializes the field type F using the given serializer.
source§

impl<'a, F: Serialize<S> + Clone, S: Fallible + ?Sized> SerializeWith<Cow<'a, F>, S> for AsOwned

source§

fn serialize_with( field: &Cow<'a, F>, serializer: &mut S ) -> Result<Self::Resolver, S::Error>

Serializes the field type F using the given serializer.
source§

impl<'a, S: Serializer + ?Sized> SerializeWith<Cow<'a, str>, S> for AsOwned

source§

fn serialize_with( field: &Cow<'a, str>, serializer: &mut S ) -> Result<Self::Resolver, S::Error>

Serializes the field type F using the given serializer.

Auto Trait Implementations§

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> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

source§

fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
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> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.