#[repr(transparent)]pub struct Ref<'scope, 'data, T: Wrapper<'scope, 'data>>(_, _, _);
Expand description
An unrooted reference to Julia data.
Pointer wrappers are generally guaranteed to wrap valid, rooted data. In some cases this
guarantee is too strong. The garbage collector uses the roots as a starting point to
determine what values can be reached, as long as you can guarantee a value is reachable it’s
safe to use. Whenever data is not rooted jlrs returns a Ref
. Because it’s not rooted it’s
unsafe to use.
Implementations
sourceimpl<'scope, 'data, T: Wrapper<'scope, 'data>> Ref<'scope, 'data, T>
impl<'scope, 'data, T: Wrapper<'scope, 'data>> Ref<'scope, 'data, T>
sourcepub fn undefined_ref() -> Ref<'scope, 'data, T>
pub fn undefined_ref() -> Ref<'scope, 'data, T>
An undefined reference, i.e. a null pointer.
sourcepub fn is_undefined(self) -> bool
pub fn is_undefined(self) -> bool
Returns true
if the reference is undefined.
sourcepub unsafe fn wrapper(self) -> Option<T>
pub unsafe fn wrapper(self) -> Option<T>
Assume the reference still points to valid Julia data and convert it to its wrapper type.
Returns None
if the reference is undefined.
Safety: a reference is only valid as long as it’s reachable through some rooted value. It’s the caller’s responsibility to ensure the result is never used after it becomes unreachable.
sourcepub unsafe fn wrapper_unchecked(self) -> T
pub unsafe fn wrapper_unchecked(self) -> T
Assume the reference still points to valid Julia data and convert it to its wrapper type.
Safety: this method doesn’t check if the reference is undefined, a reference is only valid as long as it’s reachable through some rooted value. It’s the caller’s responsibility to ensure the result is never used after it becomes unreachable.
sourcepub unsafe fn root<'target, 'current, S, F>(
self,
scope: S
) -> JlrsResult<S::Value> where
S: Scope<'target, 'current, 'data, F>,
F: Frame<'current>,
pub unsafe fn root<'target, 'current, S, F>(
self,
scope: S
) -> JlrsResult<S::Value> where
S: Scope<'target, 'current, 'data, F>,
F: Frame<'current>,
Assume the reference still points to valid Julia data and root it in scope
. Returns an
error if the reference is undefined.
Safety: a reference is only valid as long as it’s reachable through some rooted value.
sourcepub unsafe fn value(self) -> Option<Value<'scope, 'data>>
pub unsafe fn value(self) -> Option<Value<'scope, 'data>>
Assume the reference still points to valid Julia data and convert it to a Value
. Returns
None
if the reference is undefined.
Safety: a reference is only valid as long as it’s reachable through some rooted value. It’s the caller’s responsibility to ensure the result is never used after it becomes unreachable.
sourcepub unsafe fn value_unchecked(self) -> Value<'scope, 'data>
pub unsafe fn value_unchecked(self) -> Value<'scope, 'data>
Assume the reference still points to valid Julia data and convert it to a Value
.
Safety: this method doesn’t check if the reference is undefined, a reference is only valid as long as it’s reachable through some rooted value. It’s the caller’s responsibility to ensure the result is never used after it becomes unreachable.
Trait Implementations
sourceimpl<'scope, 'data, T: Clone + Wrapper<'scope, 'data>> Clone for Ref<'scope, 'data, T> where
T::Wraps: Clone,
impl<'scope, 'data, T: Clone + Wrapper<'scope, 'data>> Clone for Ref<'scope, 'data, T> where
T::Wraps: Clone,
impl<'scope, 'data, T: Copy + Wrapper<'scope, 'data>> Copy for Ref<'scope, 'data, T> where
T::Wraps: Copy,
Auto Trait Implementations
impl<'scope, 'data, T> RefUnwindSafe for Ref<'scope, 'data, T> where
<T as Wrapper<'scope, 'data>>::Wraps: RefUnwindSafe,
impl<'scope, 'data, T> !Send for Ref<'scope, 'data, T>
impl<'scope, 'data, T> !Sync for Ref<'scope, 'data, T>
impl<'scope, 'data, T> Unpin for Ref<'scope, 'data, T>
impl<'scope, 'data, T> UnwindSafe for Ref<'scope, 'data, T> where
<T as Wrapper<'scope, 'data>>::Wraps: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more