Struct rkyv::niche::option_box::ArchivedOptionBox
source · #[repr(transparent)]pub struct ArchivedOptionBox<T: ArchivePointee + ?Sized> { /* private fields */ }
Expand description
A niched archived Option<Box<T>>
.
It uses less space by storing the None
variant as a null pointer.
Implementations§
source§impl<T: ArchivePointee + ?Sized> ArchivedOptionBox<T>
impl<T: ArchivePointee + ?Sized> ArchivedOptionBox<T>
sourcepub fn as_ref(&self) -> Option<&ArchivedBox<T>>
pub fn as_ref(&self) -> Option<&ArchivedBox<T>>
Converts to an Option<&ArchivedBox<T>>
.
sourcepub fn as_mut(&mut self) -> Option<&mut ArchivedBox<T>>
pub fn as_mut(&mut self) -> Option<&mut ArchivedBox<T>>
Converts to an Option<&mut ArchivedBox<T>>
.
sourcepub fn as_pin_ref(self: Pin<&Self>) -> Option<Pin<&ArchivedBox<T>>>
pub fn as_pin_ref(self: Pin<&Self>) -> Option<Pin<&ArchivedBox<T>>>
Converts from Pin<&ArchivedOptionBox<T>>
to Option<Pin<&ArchivedBox<T>>>
.
sourcepub fn as_pin_mut(self: Pin<&mut Self>) -> Option<Pin<&mut ArchivedBox<T>>>
pub fn as_pin_mut(self: Pin<&mut Self>) -> Option<Pin<&mut ArchivedBox<T>>>
Converts from Pin<&mut ArchivedOption<T>>
to Option<Pin<&mut ArchivedBox<T>>>
.
sourcepub fn iter(&self) -> Iter<'_, ArchivedBox<T>>
pub fn iter(&self) -> Iter<'_, ArchivedBox<T>>
Returns an iterator over the possibly contained value.
sourcepub fn iter_mut(&mut self) -> IterMut<'_, ArchivedBox<T>>
pub fn iter_mut(&mut self) -> IterMut<'_, ArchivedBox<T>>
Returns a mutable iterator over the possibly contained value.
source§impl<T: ArchivePointee + ?Sized> ArchivedOptionBox<T>where
T::ArchivedMetadata: Default,
impl<T: ArchivePointee + ?Sized> ArchivedOptionBox<T>where T::ArchivedMetadata: Default,
sourcepub unsafe fn resolve_from_option<U: ArchiveUnsized<Archived = T> + ?Sized>(
field: Option<&U>,
pos: usize,
resolver: OptionBoxResolver<U::MetadataResolver>,
out: *mut Self
)
pub unsafe fn resolve_from_option<U: ArchiveUnsized<Archived = T> + ?Sized>( field: Option<&U>, pos: usize, resolver: OptionBoxResolver<U::MetadataResolver>, out: *mut Self )
Resolves an ArchivedOptionBox<T::Archived>
from an Option<&T>
.
Safety
pos
must be the position ofout
within the archiveresolver
must be the result of serializingfield
sourcepub fn serialize_from_option<U, S>(
field: Option<&U>,
serializer: &mut S
) -> Result<OptionBoxResolver<U::MetadataResolver>, S::Error>where
U: SerializeUnsized<S, Archived = T> + ?Sized,
S: Serializer + ?Sized,
pub fn serialize_from_option<U, S>( field: Option<&U>, serializer: &mut S ) -> Result<OptionBoxResolver<U::MetadataResolver>, S::Error>where U: SerializeUnsized<S, Archived = T> + ?Sized, S: Serializer + ?Sized,
Serializes an ArchivedOptionBox<T::Archived>
from an Option<&T>
.
Trait Implementations§
source§impl<T: ArchivePointee + ?Sized> Debug for ArchivedOptionBox<T>where
T::ArchivedMetadata: Debug,
impl<T: ArchivePointee + ?Sized> Debug for ArchivedOptionBox<T>where T::ArchivedMetadata: Debug,
source§impl<T, D> DeserializeWith<ArchivedOptionBox<<T as ArchiveUnsized>::Archived>, Option<Box<T, Global>>, D> for Nichewhere
T: ArchiveUnsized + ?Sized,
T::Archived: DeserializeUnsized<T, D>,
D: Fallible + ?Sized,
impl<T, D> DeserializeWith<ArchivedOptionBox<<T as ArchiveUnsized>::Archived>, Option<Box<T, Global>>, D> for Nichewhere T: ArchiveUnsized + ?Sized, T::Archived: DeserializeUnsized<T, D>, D: Fallible + ?Sized,
source§fn deserialize_with(
field: &ArchivedOptionBox<T::Archived>,
deserializer: &mut D
) -> Result<Option<Box<T>>, D::Error>
fn deserialize_with( field: &ArchivedOptionBox<T::Archived>, deserializer: &mut D ) -> Result<Option<Box<T>>, D::Error>
Deserializes the field type
F
using the given deserializer.source§impl<T: ArchivePointee + Hash + ?Sized> Hash for ArchivedOptionBox<T>
impl<T: ArchivePointee + Hash + ?Sized> Hash for ArchivedOptionBox<T>
source§impl<T: ArchivePointee + Ord + ?Sized> Ord for ArchivedOptionBox<T>
impl<T: ArchivePointee + Ord + ?Sized> Ord for ArchivedOptionBox<T>
source§impl<T: ArchivePointee + PartialEq + ?Sized> PartialEq<ArchivedOptionBox<T>> for ArchivedOptionBox<T>
impl<T: ArchivePointee + PartialEq + ?Sized> PartialEq<ArchivedOptionBox<T>> for ArchivedOptionBox<T>
source§impl<T, U> PartialEq<ArchivedOptionBox<T>> for Option<Box<U>>where
T: ArchivePointee + PartialEq<U> + ?Sized,
U: ?Sized,
impl<T, U> PartialEq<ArchivedOptionBox<T>> for Option<Box<U>>where T: ArchivePointee + PartialEq<U> + ?Sized, U: ?Sized,
source§fn eq(&self, other: &ArchivedOptionBox<T>) -> bool
fn eq(&self, other: &ArchivedOptionBox<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<T, U> PartialEq<Option<Box<T, Global>>> for ArchivedOptionBox<U>where
T: ?Sized,
U: ArchivePointee + PartialEq<T> + ?Sized,
impl<T, U> PartialEq<Option<Box<T, Global>>> for ArchivedOptionBox<U>where T: ?Sized, U: ArchivePointee + PartialEq<T> + ?Sized,
source§impl<T: ArchivePointee + PartialOrd + ?Sized> PartialOrd<ArchivedOptionBox<T>> for ArchivedOptionBox<T>
impl<T: ArchivePointee + PartialOrd + ?Sized> PartialOrd<ArchivedOptionBox<T>> for ArchivedOptionBox<T>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<T: ArchivePointee + Eq + ?Sized> Eq for ArchivedOptionBox<T>
Auto Trait Implementations§
impl<T: ?Sized> RefUnwindSafe for ArchivedOptionBox<T>where T: RefUnwindSafe, <T as ArchivePointee>::ArchivedMetadata: RefUnwindSafe,
impl<T: ?Sized> Send for ArchivedOptionBox<T>where T: Send, <T as ArchivePointee>::ArchivedMetadata: Send,
impl<T: ?Sized> Sync for ArchivedOptionBox<T>where T: Sync, <T as ArchivePointee>::ArchivedMetadata: Sync,
impl<T> !Unpin for ArchivedOptionBox<T>
impl<T: ?Sized> UnwindSafe for ArchivedOptionBox<T>where T: UnwindSafe, <T as ArchivePointee>::ArchivedMetadata: UnwindSafe,
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> CallHasher for Twhere
T: Hash + ?Sized,
impl<T> CallHasher for Twhere T: Hash + ?Sized,
source§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.