pub struct AsString;
Expand description
A wrapper that attempts to convert a type to and from UTF-8.
Types like OsString
and PathBuf
aren’t guaranteed to be encoded as UTF-8, but they usually
are anyway. Using this wrapper will archive them as if they were regular String
s.
Regular serializers don’t support the custom error handling needed for this type by default. To
use this wrapper, a custom serializer with an error type satisfying
<S as Fallible>::Error: From<AsStringError>
must be provided.
§Example
use std::{ffi::OsString, path::PathBuf};
use rkyv::{Archive, with::AsString};
#[derive(Archive)]
struct Example {
#[with(AsString)]
os_string: OsString,
#[with(AsString)]
path: PathBuf,
}
Trait Implementations§
source§impl ArchiveWith<OsString> for AsString
impl ArchiveWith<OsString> for AsString
§type Archived = ArchivedString
type Archived = ArchivedString
The archived type of a
With<F, Self>
.§type Resolver = StringResolver
type Resolver = StringResolver
The resolver of a
With<F, Self>
.source§impl ArchiveWith<PathBuf> for AsString
impl ArchiveWith<PathBuf> for AsString
§type Archived = ArchivedString
type Archived = ArchivedString
The archived type of a
With<F, Self>
.§type Resolver = StringResolver
type Resolver = StringResolver
The resolver of a
With<F, Self>
.source§impl<D: Fallible + ?Sized> DeserializeWith<ArchivedString, OsString, D> for AsString
impl<D: Fallible + ?Sized> DeserializeWith<ArchivedString, OsString, D> for AsString
source§fn deserialize_with(
field: &ArchivedString,
_: &mut D,
) -> Result<OsString, D::Error>
fn deserialize_with( field: &ArchivedString, _: &mut D, ) -> Result<OsString, D::Error>
Deserializes the field type
F
using the given deserializer.source§impl<D: Fallible + ?Sized> DeserializeWith<ArchivedString, PathBuf, D> for AsString
impl<D: Fallible + ?Sized> DeserializeWith<ArchivedString, PathBuf, D> for AsString
source§fn deserialize_with(
field: &ArchivedString,
_: &mut D,
) -> Result<PathBuf, D::Error>
fn deserialize_with( field: &ArchivedString, _: &mut D, ) -> Result<PathBuf, D::Error>
Deserializes the field type
F
using the given deserializer.Auto Trait Implementations§
impl Freeze for AsString
impl RefUnwindSafe for AsString
impl Send for AsString
impl Sync for AsString
impl Unpin for AsString
impl UnwindSafe for AsString
Blanket Implementations§
source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more