Skip to main content

Persistent

Struct Persistent 

Source
pub struct Persistent<T: GarbageCollected> { /* private fields */ }
Expand description

Persistent is a way to create a strong pointer from an off-heap object to another on-heap object. As long as the Persistent handle is alive the GC will keep the object pointed to alive. The Persistent handle is always a GC root from the point of view of the GC. Persistent must be constructed and destructed in the same thread.

Implementations§

Source§

impl<T: GarbageCollected> Persistent<T>

Source

pub fn empty() -> Self

Create a new empty Persistent which may be set later.

Source

pub fn new(other: &impl GetRustObj<T>) -> Self

Create a new Persistent and initialize it with an object.

Source

pub fn set(&mut self, other: &impl GetRustObj<T>)

Set the object pointed to by this Persistent .

Source

pub fn get(&self) -> Option<&T>

Borrow the object pointed to by this Persistent .

Trait Implementations§

Source§

impl<T: GarbageCollected> Debug for Persistent<T>

Source§

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

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

impl<T: GarbageCollected> Drop for Persistent<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Persistent<T>

§

impl<T> RefUnwindSafe for Persistent<T>
where T: RefUnwindSafe,

§

impl<T> !Send for Persistent<T>

§

impl<T> !Sync for Persistent<T>

§

impl<T> Unpin for Persistent<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Persistent<T>

§

impl<T> UnwindSafe for Persistent<T>
where T: UnwindSafe,

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> 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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,