#[repr(C)]pub struct External<T: 'static> {
pub adjusted_size: i64,
/* private fields */
}
Fields§
§adjusted_size: i64
Implementations§
Source§impl<T: 'static> External<T>
impl<T: 'static> External<T>
pub fn new(value: T) -> Self
Sourcepub unsafe fn inner_from_raw_mut(
unknown_tagged_object: *mut c_void,
) -> Option<&'static mut T>
pub unsafe fn inner_from_raw_mut( unknown_tagged_object: *mut c_void, ) -> Option<&'static mut T>
Turn a raw pointer (from napi) pointing to an External into a mutable reference to the inner object.
§Safety
The unknown_tagged_object
raw pointer must point to an External<T>
struct.
Sourcepub unsafe fn inner_from_raw(
unknown_tagged_object: *mut c_void,
) -> Option<&'static T>
pub unsafe fn inner_from_raw( unknown_tagged_object: *mut c_void, ) -> Option<&'static T>
Turn a raw pointer (from napi) pointing to an External into a reference inner object.
§Safety
The unknown_tagged_object
raw pointer must point to an External<T>
struct.
Sourcepub fn new_with_size_hint(value: T, size_hint: usize) -> Self
pub fn new_with_size_hint(value: T, size_hint: usize) -> Self
size_hint
is a value to tell Node.js GC how much memory is used by this External
object.
If getting the exact size_hint
is difficult, you can provide an approximate value, it’s only effect to the GC.
If your External
object is not effect to GC, you can use External::new
instead.
Sourcepub fn into_unknown(self, env: &Env) -> Result<Unknown<'_>>
pub fn into_unknown(self, env: &Env) -> Result<Unknown<'_>>
convert External<T>
to Unknown
Sourcepub fn into_js_external(self, env: &Env) -> Result<JsExternal<'_>>
pub fn into_js_external(self, env: &Env) -> Result<JsExternal<'_>>
Convert External<T>
to JsExternal
Trait Implementations§
Source§impl<T: 'static> FromNapiMutRef for External<T>
impl<T: 'static> FromNapiMutRef for External<T>
Source§unsafe fn from_napi_mut_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static mut Self>
unsafe fn from_napi_mut_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static mut Self>
Safety Read more
Source§impl<T: 'static> FromNapiRef for External<T>
impl<T: 'static> FromNapiRef for External<T>
Source§unsafe fn from_napi_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static Self>
unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static Self>
Safety Read more
Source§impl<T: 'static> ToNapiValue for External<T>
impl<T: 'static> ToNapiValue for External<T>
Source§unsafe fn to_napi_value(env: napi_env, val: Self) -> Result<napi_value>
unsafe fn to_napi_value(env: napi_env, val: Self) -> Result<napi_value>
Safety Read more
fn into_unknown(self, env: &Env) -> Result<Unknown<'_>>
Source§impl<T: 'static> ValidateNapiValue for &External<T>
impl<T: 'static> ValidateNapiValue for &External<T>
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Source§impl<T: 'static> ValidateNapiValue for &mut External<T>
impl<T: 'static> ValidateNapiValue for &mut External<T>
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Auto Trait Implementations§
impl<T> Freeze for External<T>where
T: Freeze,
impl<T> RefUnwindSafe for External<T>where
T: RefUnwindSafe,
impl<T> Send for External<T>where
T: Send,
impl<T> Sync for External<T>where
T: Sync,
impl<T> Unpin for External<T>where
T: Unpin,
impl<T> UnwindSafe for External<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more