pub struct Weak<'scope, 'data, T: ManagedPriv<'scope, 'data>>(/* private fields */);Expand description
A reference to Julia data that is not guaranteed to be rooted.
Managed types 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 Weak. Because it’s not rooted it’s
unsafe to use.
Implementations§
Source§impl<'scope, 'data> Weak<'scope, 'data, TypedValue<'scope, 'data, AnyType>>
impl<'scope, 'data> Weak<'scope, 'data, TypedValue<'scope, 'data, AnyType>>
pub fn from_value_ref(value_ref: WeakValue<'scope, 'data>) -> Self
Source§impl<'scope, 'data, W: Managed<'scope, 'data>> Weak<'scope, 'data, W>
impl<'scope, 'data, W: Managed<'scope, 'data>> Weak<'scope, 'data, W>
Sourcepub unsafe fn root<'target, Tgt>(
self,
target: Tgt,
) -> Tgt::Data<'data, W::InScope<'target>>where
Tgt: Target<'target>,
pub unsafe fn root<'target, Tgt>(
self,
target: Tgt,
) -> Tgt::Data<'data, W::InScope<'target>>where
Tgt: Target<'target>,
Use target to root self.
Safety: The data pointed to by self must not have been freed by the GC yet.
Sourcepub unsafe fn as_managed(self) -> W
pub unsafe fn as_managed(self) -> W
Assume the reference still points to valid managed data and convert it to its managed type.
Safety: a reference is only guaranteed to be valid as long as it’s reachable from some GC root. If the reference is unreachable, the GC can free it. The GC can run whenever a safepoint is reached, this is typically the case when new Julia data is allocated.
Sourcepub unsafe fn as_value(self) -> Value<'scope, 'data>
pub unsafe fn as_value(self) -> Value<'scope, 'data>
Assume the reference still points to valid managed data and convert it to a Value.
Safety: a reference is only guaranteed to be valid as long as it’s reachable from some GC root. If the reference is unreachable, the GC can free it. The GC can run whenever a safepoint is reached, this is typically the case when new Julia data is allocated.
Sourcepub unsafe fn assume_owned(self) -> Weak<'scope, 'static, W::WithData<'static>>
pub unsafe fn assume_owned(self) -> Weak<'scope, 'static, W::WithData<'static>>
Extends the 'data lifetime to 'static.
Safety: this method should only be used when no data borrowed from Rust is referenced by this Julia data.
Sourcepub fn leak(self) -> Weak<'static, 'data, W::InScope<'static>>
pub fn leak(self) -> Weak<'static, 'data, W::InScope<'static>>
Extends the 'scope lifetime to 'static, which allows this reference to Julia data to
be leaked from a scope.
Safety: this method should only be called to return Julia data from a ccalled function
or when storing Julia data in a foreign type.
Trait Implementations§
Source§impl CCallReturn for Weak<'static, 'static, DataType<'static>>
impl CCallReturn for Weak<'static, 'static, DataType<'static>>
Source§type CCallReturnType = Value<'static, 'static>
type CCallReturnType = Value<'static, 'static>
ccalled function.Source§type FunctionReturnType = DataType<'static>
type FunctionReturnType = DataType<'static>
Source§type ReturnAs = Weak<'static, 'static, DataType<'static>>
type ReturnAs = Weak<'static, 'static, DataType<'static>>
Self::return_or_throw.Source§unsafe fn return_or_throw(self) -> Self::ReturnAs
unsafe fn return_or_throw(self) -> Self::ReturnAs
self to data that can be returned to Julia, or throw an exception. Read moreSource§impl CCallReturn for Weak<'static, 'static, Expr<'static>>
impl CCallReturn for Weak<'static, 'static, Expr<'static>>
Source§type CCallReturnType = Value<'static, 'static>
type CCallReturnType = Value<'static, 'static>
ccalled function.Source§type FunctionReturnType = Expr<'static>
type FunctionReturnType = Expr<'static>
Source§type ReturnAs = Weak<'static, 'static, Expr<'static>>
type ReturnAs = Weak<'static, 'static, Expr<'static>>
Self::return_or_throw.Source§unsafe fn return_or_throw(self) -> Self::ReturnAs
unsafe fn return_or_throw(self) -> Self::ReturnAs
self to data that can be returned to Julia, or throw an exception. Read moreSource§impl CCallReturn for Weak<'static, 'static, Module<'static>>
impl CCallReturn for Weak<'static, 'static, Module<'static>>
Source§type CCallReturnType = Value<'static, 'static>
type CCallReturnType = Value<'static, 'static>
ccalled function.Source§type FunctionReturnType = Module<'static>
type FunctionReturnType = Module<'static>
Source§type ReturnAs = Weak<'static, 'static, Module<'static>>
type ReturnAs = Weak<'static, 'static, Module<'static>>
Self::return_or_throw.Source§unsafe fn return_or_throw(self) -> Self::ReturnAs
unsafe fn return_or_throw(self) -> Self::ReturnAs
self to data that can be returned to Julia, or throw an exception. Read moreSource§impl CCallReturn for Weak<'static, 'static, NamedTuple<'static, 'static>>
impl CCallReturn for Weak<'static, 'static, NamedTuple<'static, 'static>>
Source§type CCallReturnType = Value<'static, 'static>
type CCallReturnType = Value<'static, 'static>
ccalled function.Source§type FunctionReturnType = NamedTuple<'static, 'static>
type FunctionReturnType = NamedTuple<'static, 'static>
Source§type ReturnAs = Weak<'static, 'static, NamedTuple<'static, 'static>>
type ReturnAs = Weak<'static, 'static, NamedTuple<'static, 'static>>
Self::return_or_throw.Source§unsafe fn return_or_throw(self) -> Self::ReturnAs
unsafe fn return_or_throw(self) -> Self::ReturnAs
self to data that can be returned to Julia, or throw an exception. Read moreSource§impl CCallReturn for Weak<'static, 'static, SimpleVector<'static>>
impl CCallReturn for Weak<'static, 'static, SimpleVector<'static>>
Source§type CCallReturnType = Value<'static, 'static>
type CCallReturnType = Value<'static, 'static>
ccalled function.Source§type FunctionReturnType = SimpleVector<'static>
type FunctionReturnType = SimpleVector<'static>
Source§type ReturnAs = Weak<'static, 'static, SimpleVector<'static>>
type ReturnAs = Weak<'static, 'static, SimpleVector<'static>>
Self::return_or_throw.Source§unsafe fn return_or_throw(self) -> Self::ReturnAs
unsafe fn return_or_throw(self) -> Self::ReturnAs
self to data that can be returned to Julia, or throw an exception. Read moreSource§impl CCallReturn for Weak<'static, 'static, JuliaString<'static>>
impl CCallReturn for Weak<'static, 'static, JuliaString<'static>>
Source§type CCallReturnType = Value<'static, 'static>
type CCallReturnType = Value<'static, 'static>
ccalled function.Source§type FunctionReturnType = JuliaString<'static>
type FunctionReturnType = JuliaString<'static>
Source§type ReturnAs = Weak<'static, 'static, JuliaString<'static>>
type ReturnAs = Weak<'static, 'static, JuliaString<'static>>
Self::return_or_throw.Source§unsafe fn return_or_throw(self) -> Self::ReturnAs
unsafe fn return_or_throw(self) -> Self::ReturnAs
self to data that can be returned to Julia, or throw an exception. Read moreSource§impl CCallReturn for Weak<'static, 'static, Symbol<'static>>
impl CCallReturn for Weak<'static, 'static, Symbol<'static>>
Source§type CCallReturnType = Value<'static, 'static>
type CCallReturnType = Value<'static, 'static>
ccalled function.Source§type FunctionReturnType = Symbol<'static>
type FunctionReturnType = Symbol<'static>
Source§type ReturnAs = Weak<'static, 'static, Symbol<'static>>
type ReturnAs = Weak<'static, 'static, Symbol<'static>>
Self::return_or_throw.Source§unsafe fn return_or_throw(self) -> Self::ReturnAs
unsafe fn return_or_throw(self) -> Self::ReturnAs
self to data that can be returned to Julia, or throw an exception. Read moreSource§impl CCallReturn for Weak<'static, 'static, TypeName<'static>>
impl CCallReturn for Weak<'static, 'static, TypeName<'static>>
Source§type CCallReturnType = Value<'static, 'static>
type CCallReturnType = Value<'static, 'static>
ccalled function.Source§type FunctionReturnType = TypeName<'static>
type FunctionReturnType = TypeName<'static>
Source§type ReturnAs = Weak<'static, 'static, TypeName<'static>>
type ReturnAs = Weak<'static, 'static, TypeName<'static>>
Self::return_or_throw.Source§unsafe fn return_or_throw(self) -> Self::ReturnAs
unsafe fn return_or_throw(self) -> Self::ReturnAs
self to data that can be returned to Julia, or throw an exception. Read moreSource§impl CCallReturn for Weak<'static, 'static, TypeVar<'static>>
impl CCallReturn for Weak<'static, 'static, TypeVar<'static>>
Source§type CCallReturnType = Value<'static, 'static>
type CCallReturnType = Value<'static, 'static>
ccalled function.Source§type FunctionReturnType = TypeVar<'static>
type FunctionReturnType = TypeVar<'static>
Source§type ReturnAs = Weak<'static, 'static, TypeVar<'static>>
type ReturnAs = Weak<'static, 'static, TypeVar<'static>>
Self::return_or_throw.Source§unsafe fn return_or_throw(self) -> Self::ReturnAs
unsafe fn return_or_throw(self) -> Self::ReturnAs
self to data that can be returned to Julia, or throw an exception. Read moreSource§impl CCallReturn for Weak<'static, 'static, Union<'static>>
impl CCallReturn for Weak<'static, 'static, Union<'static>>
Source§type CCallReturnType = Value<'static, 'static>
type CCallReturnType = Value<'static, 'static>
ccalled function.Source§type FunctionReturnType = Union<'static>
type FunctionReturnType = Union<'static>
Source§type ReturnAs = Weak<'static, 'static, Union<'static>>
type ReturnAs = Weak<'static, 'static, Union<'static>>
Self::return_or_throw.Source§unsafe fn return_or_throw(self) -> Self::ReturnAs
unsafe fn return_or_throw(self) -> Self::ReturnAs
self to data that can be returned to Julia, or throw an exception. Read moreSource§impl CCallReturn for Weak<'static, 'static, UnionAll<'static>>
impl CCallReturn for Weak<'static, 'static, UnionAll<'static>>
Source§type CCallReturnType = Value<'static, 'static>
type CCallReturnType = Value<'static, 'static>
ccalled function.Source§type FunctionReturnType = UnionAll<'static>
type FunctionReturnType = UnionAll<'static>
Source§type ReturnAs = Weak<'static, 'static, UnionAll<'static>>
type ReturnAs = Weak<'static, 'static, UnionAll<'static>>
Self::return_or_throw.Source§unsafe fn return_or_throw(self) -> Self::ReturnAs
unsafe fn return_or_throw(self) -> Self::ReturnAs
self to data that can be returned to Julia, or throw an exception. Read moreSource§impl CCallReturn for Weak<'static, 'static, Value<'static, 'static>>
impl CCallReturn for Weak<'static, 'static, Value<'static, 'static>>
Source§type CCallReturnType = Value<'static, 'static>
type CCallReturnType = Value<'static, 'static>
ccalled function.Source§type FunctionReturnType = Value<'static, 'static>
type FunctionReturnType = Value<'static, 'static>
Source§type ReturnAs = Weak<'static, 'static, Value<'static, 'static>>
type ReturnAs = Weak<'static, 'static, Value<'static, 'static>>
Self::return_or_throw.Source§unsafe fn return_or_throw(self) -> Self::ReturnAs
unsafe fn return_or_throw(self) -> Self::ReturnAs
self to data that can be returned to Julia, or throw an exception. Read moreimpl<'scope, 'data, T> Copy for Weak<'scope, 'data, T>where
T: ManagedPriv<'scope, 'data>,
Source§impl<'scope, 'data, T> ManagedWeak<'scope, 'data> for Weak<'scope, 'data, T>
impl<'scope, 'data, T> ManagedWeak<'scope, 'data> for Weak<'scope, 'data, T>
Auto Trait Implementations§
impl<'scope, 'data, T> !Send for Weak<'scope, 'data, T>
impl<'scope, 'data, T> !Sync for Weak<'scope, 'data, T>
impl<'scope, 'data, T> Freeze for Weak<'scope, 'data, T>
impl<'scope, 'data, T> RefUnwindSafe for Weak<'scope, 'data, T>where
<T as ManagedPriv<'scope, 'data>>::Wraps: RefUnwindSafe,
impl<'scope, 'data, T> Unpin for Weak<'scope, 'data, T>
impl<'scope, 'data, T> UnsafeUnpin for Weak<'scope, 'data, T>
impl<'scope, 'data, T> UnwindSafe for Weak<'scope, 'data, T>where
<T as ManagedPriv<'scope, 'data>>::Wraps: RefUnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Compatible<T> for Twhere
T: ValidLayout,
Source§impl<T> CompatibleCast for Twhere
T: ValidLayout,
impl<T> CompatibleCast for Twhere
T: ValidLayout,
type Inner = T
type Output<U> = U
Source§fn compatible_cast<U>(&self) -> &<T as CompatibleCast>::Output<U>where
T: Compatible<U>,
fn compatible_cast<U>(&self) -> &<T as CompatibleCast>::Output<U>where
T: Compatible<U>,
&Self to &U, &[Self] to &[U], and &[Self; N] to &[U; N].Source§fn compatible_cast_mut<U>(&mut self) -> &mut <T as CompatibleCast>::Output<U>where
T: Compatible<U>,
fn compatible_cast_mut<U>(&mut self) -> &mut <T as CompatibleCast>::Output<U>where
T: Compatible<U>,
&mut Self to &mut U, &mut [Self] to &mut [U], and &mut [Self; N] to
&mut [U; N].