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
sourceimpl 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>
.
sourceimpl 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>
.
sourceimpl<D: Fallible + ?Sized> DeserializeWith<ArchivedString, OsString, D> for AsString
impl<D: Fallible + ?Sized> DeserializeWith<ArchivedString, OsString, D> for AsString
sourcefn 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.
sourceimpl<D: Fallible + ?Sized> DeserializeWith<ArchivedString, PathBuf, D> for AsString
impl<D: Fallible + ?Sized> DeserializeWith<ArchivedString, PathBuf, D> for AsString
sourcefn 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.
sourceimpl<S: Fallible + ?Sized> SerializeWith<OsString, S> for AsString where
S::Error: From<AsStringError>,
str: SerializeUnsized<S>,
impl<S: Fallible + ?Sized> SerializeWith<OsString, S> for AsString where
S::Error: From<AsStringError>,
str: SerializeUnsized<S>,
sourceimpl<S: Fallible + ?Sized> SerializeWith<PathBuf, S> for AsString where
S::Error: From<AsStringError>,
str: SerializeUnsized<S>,
impl<S: Fallible + ?Sized> SerializeWith<PathBuf, S> for AsString where
S::Error: From<AsStringError>,
str: SerializeUnsized<S>,
Auto Trait Implementations
impl RefUnwindSafe for AsString
impl Send for AsString
impl Sync for AsString
impl Unpin for AsString
impl UnwindSafe for AsString
Blanket Implementations
sourceimpl<T> ArchivePointee for T
impl<T> ArchivePointee for T
type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
sourcefn pointer_metadata(_: &Self::ArchivedMetadata) -> <Self as Pointee>::Metadata
fn pointer_metadata(_: &Self::ArchivedMetadata) -> <Self as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more