pub struct Saved<'a, T: TypedExternal + ?Sized> {
sexp: SEXP,
_marker: PhantomData<&'a T>,
}Expand description
What a save of a T kept, handed to the type’s rebuild hook
(#[externalptr(rebuild = path)]) when a pointer restored from a saved
session is first used.
The type’s generated Sidecar getters read the saved values through it,
as through a live handle: Self::keys(saved). Only Sidecar fields have
a slot in the save; a struct field or a Computed field is gone with the
Rust value, so a type whose rebuild needs one keeps it in a Sidecar.
The save names its slots after the fields’ R names (the
#[r_data(name = "..")] value, else the Rust field name), so a field is
read by name whatever fields the version that saved it had (#2187,
#2215). A field the save
lacks (added since) reads as None through the generated
Self::try_keys(saved); the plain getter raises the classed error
RESTORED_MISSING_SLOT_CLASS.
Fields§
§sexp: SEXP§_marker: PhantomData<&'a T>Implementations§
Source§impl<T: TypedExternal + ?Sized> Saved<'_, T>
impl<T: TypedExternal + ?Sized> Saved<'_, T>
Sourcepub(crate) unsafe fn new(sexp: SEXP) -> Self
pub(crate) unsafe fn new(sexp: SEXP) -> Self
The handle over sexp, a pointer for a T restored without its
value.
§Safety
sexp must be a live EXTPTRSXP built by ExternalPtr for a T by
some version of its crate, rooted for the handle’s lifetime.
Sourcepub fn has(&self, field: &str) -> bool
pub fn has(&self, field: &str) -> bool
Whether the save has a slot for the Sidecar field field, given by
its R name: the #[r_data(name = "..")] value, else the Rust field
name. The generated Self::try_<field>(saved) getters say the same
with the field’s type, checked by the compiler.
The R name is the save format (#2215): a save names each slot after it. Renaming the Rust field keeps earlier saves readable; renaming the R name orphans the field’s slot in every earlier save, which then reads as a field the save lacks.
Trait Implementations§
impl<T: TypedExternal + ?Sized> Owner for Saved<'_, T>
Source§impl<T: TypedExternal + ?Sized> SidecarOwner<T> for Saved<'_, T>
impl<T: TypedExternal + ?Sized> SidecarOwner<T> for Saved<'_, T>
Source§fn __mx_read(&self) -> SidecarRead<'_, T>
fn __mx_read(&self) -> SidecarRead<'_, T>
Saved
handle, the restored pointer alone.Auto Trait Implementations§
impl<'a, T> Freeze for Saved<'a, T>
impl<'a, T> RefUnwindSafe for Saved<'a, T>
impl<'a, T> Send for Saved<'a, T>
impl<'a, T> Sync for Saved<'a, T>
impl<'a, T> Unpin for Saved<'a, T>
impl<'a, T> UnsafeUnpin for Saved<'a, T>
impl<'a, T> UnwindSafe for Saved<'a, T>
Blanket Implementations§
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
Source§impl<T> RDebug for Twhere
T: Debug,
impl<T> RDebug for Twhere
T: Debug,
Source§impl<T> SizeHint for Twhere
T: ?Sized,
impl<T> SizeHint for Twhere
T: ?Sized,
Source§default fn lower_bound(&self) -> usize
default fn lower_bound(&self) -> usize
core_io_internals)[u8; 12] could return any value between 0 and
12 inclusively as a correct implementation. Read moreSource§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read moreLayout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 8 bytes