pub struct ExternRef { /* private fields */ }
Expand description
Represents an opaque reference to any data within WebAssembly.
Implementations§
source§impl ExternRef
impl ExternRef
sourcepub fn new<T>(value: T) -> ExternRef
pub fn new<T>(value: T) -> ExternRef
Creates a new instance of ExternRef
wrapping the given value.
sourcepub fn strong_count(&self) -> usize
pub fn strong_count(&self) -> usize
Get the strong reference count for this ExternRef
.
Note that this loads the reference count with a SeqCst
ordering to
synchronize with other threads.
sourcepub fn ptr_eq(&self, other: &ExternRef) -> bool
pub fn ptr_eq(&self, other: &ExternRef) -> bool
Does this ExternRef
point to the same inner value as other
?
This is only pointer equality, and does not run any inner value’s
Eq
implementation.
sourcepub unsafe fn from_raw(raw: usize) -> Option<ExternRef>
pub unsafe fn from_raw(raw: usize) -> Option<ExternRef>
Creates a new strongly-owned ExternRef
from the raw value provided.
This is intended to be used in conjunction with Func::new_unchecked
,
Func::call_unchecked
, and ValRaw
with its externref
field.
This function assumes that raw
is an externref value which is
currently rooted within the Store
.
§Unsafety
This function is particularly unsafe
because raw
not only must be a
valid externref value produced prior by to_raw
but it must also be
correctly rooted within the store. When arguments are provided to a
callback with Func::new_unchecked
, for example, or returned via
Func::call_unchecked
, if a GC is performed within the store then
floating externref values are not rooted and will be GC’d, meaning that
this function will no longer be safe to call with the values cleaned up.
This function must be invoked before possible GC operations can happen
(such as calling wasm).
When in doubt try to not use this. Instead use the safe Rust APIs of
TypedFunc
and friends.
sourcepub unsafe fn to_raw(&self, store: impl AsContextMut) -> usize
pub unsafe fn to_raw(&self, store: impl AsContextMut) -> usize
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExternRef
impl !RefUnwindSafe for ExternRef
impl Send for ExternRef
impl Sync for ExternRef
impl Unpin for ExternRef
impl !UnwindSafe for ExternRef
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,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more