pub struct JsDate(/* private fields */);
Implementations§
Source§impl JsDate
impl JsDate
Sourcepub fn new(env: NapiEnv, time: f64) -> NapiResult<JsDate>
pub fn new(env: NapiEnv, time: f64) -> NapiResult<JsDate>
This API does not observe leap seconds; they are ignored, as ECMAScript aligns with POSIX time specification. This API allocates a JavaScript Date object. JavaScript Date objects are described in Section 20.3 of the ECMAScript Language Specification.
Sourcepub fn get(&self) -> NapiResult<f64>
pub fn get(&self) -> NapiResult<f64>
This API does not observe leap seconds; they are ignored, as ECMAScript aligns with POSIX time specification. Returns napi_ok if the API succeeded. If a non-date napi_value is passed in it returns napi_date_expected. This API returns the C double primitive of time value for the given JavaScript Date.
Trait Implementations§
Source§impl NapiValueCheck for JsDate
impl NapiValueCheck for JsDate
fn check(&self) -> NapiResult<bool>
Source§impl NapiValueT for JsDate
impl NapiValueT for JsDate
Source§unsafe fn cast<T: NapiValueT>(&self) -> T
unsafe fn cast<T: NapiValueT>(&self) -> T
napi_value type cast Read more
Source§fn cast_checked<T: NapiValueT>(&self) -> NapiResult<T>
fn cast_checked<T: NapiValueT>(&self) -> NapiResult<T>
Upcast to specified value
Source§fn kind(&self) -> NapiResult<NapiValuetype>
fn kind(&self) -> NapiResult<NapiValuetype>
Returns napi_ok if the API succeeded. Read more
Source§fn coerce_to_bool(&self) -> NapiResult<JsBoolean>
fn coerce_to_bool(&self) -> NapiResult<JsBoolean>
This API implements the abstract operation ToBoolean() as defined in Section 7.1.2 of the
ECMAScript Language Specification.
Source§fn coerce_coerce_to_number(&self) -> NapiResult<JsNumber>
fn coerce_coerce_to_number(&self) -> NapiResult<JsNumber>
This API implements the abstract operation ToNumber() as defined in Section 7.1.3 of the
ECMAScript Language Specification. This function potentially runs JS code if the passed-in
value is an object.
Source§fn coerce_to_object(&self) -> NapiResult<JsObject>
fn coerce_to_object(&self) -> NapiResult<JsObject>
This API implements the abstract operation ToObject() as defined in Section 7.1.13 of the
ECMAScript Language Specification.
Source§fn coerce_to_string(&self) -> NapiResult<JsString>
fn coerce_to_string(&self) -> NapiResult<JsString>
This API implements the abstract operation ToString() as defined in Section 7.1.13 of the
ECMAScript Language Specification. This function potentially runs JS code if the passed-in
value is an object.
Source§fn instance_of(&self, constructor: JsFunction) -> NapiResult<bool>
fn instance_of(&self, constructor: JsFunction) -> NapiResult<bool>
This API represents invoking the instanceof Operator on the object as defined in Section
12.10.4 of the ECMAScript Language Specification.
Source§fn equals(&self, rhs: impl NapiValueT) -> NapiResult<bool>
fn equals(&self, rhs: impl NapiValueT) -> NapiResult<bool>
This API represents the invocation of the Strict Equality algorithm as defined in
Section 7.2.14 of the ECMAScript Language Specification.
Source§fn raw(&self) -> napi_value
fn raw(&self) -> napi_value
the raw-handle of current value
Source§fn null(&self) -> NapiResult<JsNull>
fn null(&self) -> NapiResult<JsNull>
get null singleton
Source§fn undefined(&self) -> NapiResult<JsUndefined>
fn undefined(&self) -> NapiResult<JsUndefined>
get undefined singleton
Source§fn global(&self) -> NapiResult<JsGlobal>
fn global(&self) -> NapiResult<JsGlobal>
get global singleton
Source§fn throw(&self) -> NapiResult<()>
fn throw(&self) -> NapiResult<()>
value is throwable
Source§fn define_properties<P>(&self, properties: P) -> NapiResult<()>where
P: AsRef<[NapiPropertyDescriptor]>,
fn define_properties<P>(&self, properties: P) -> NapiResult<()>where
P: AsRef<[NapiPropertyDescriptor]>,
This method allows the efficient definition of multiple properties on a given object. The
properties are defined using property descriptors (see napi_property_descriptor). Given an
array of such property descriptors, this API will set the properties on the object one at a
time, as defined by DefineOwnProperty() (described in Section 9.1.6 of the ECMA-262
specification).
Source§fn gc<Finalizer>(&mut self, finalizer: Finalizer) -> NapiResult<NapiRef>
fn gc<Finalizer>(&mut self, finalizer: Finalizer) -> NapiResult<NapiRef>
This is a hook which is fired when the value is gabage-collected.
For napi >= 5, we use napi_add_finalizer,
For napi < 5, we use napi_wrap.
Source§fn finalizer<Finalizer>(&self, finalizer: Finalizer) -> NapiResult<NapiRef>
fn finalizer<Finalizer>(&self, finalizer: Finalizer) -> NapiResult<NapiRef>
Adds a napi_finalize callback which will be called when the JavaScript object in
js_object is ready for garbage collection. This API is similar to napi_wrap() except
that: Read more
Source§fn wrap<T>(
&mut self,
data: T,
finalizer: impl FnOnce(NapiEnv, T) -> NapiResult<()>,
) -> NapiResult<NapiRef>
fn wrap<T>( &mut self, data: T, finalizer: impl FnOnce(NapiEnv, T) -> NapiResult<()>, ) -> NapiResult<NapiRef>
Wraps a native instance in a JavaScript object. The native instance can be retrieved
later using napi_unwrap(). Read more
Source§fn unwrap<T>(&self) -> NapiResult<Option<&mut T>>
fn unwrap<T>(&self) -> NapiResult<Option<&mut T>>
Retrieves a native instance that was previously wrapped in a JavaScript object using
napi_wrap(). Read more
Source§fn remove_wrap<T>(&mut self) -> NapiResult<T>
fn remove_wrap<T>(&mut self) -> NapiResult<T>
Retrieves a native instance that was previously wrapped in the JavaScript object js_object
using napi_wrap() and removes the wrapping. If a finalize callback was associated with the
wrapping, it will no longer be called when the JavaScript object becomes garbage-collected.
Source§fn type_tag_object(&self, tag: &NapiTypeTag) -> NapiResult<()>
fn type_tag_object(&self, tag: &NapiTypeTag) -> NapiResult<()>
Associates the value of the type_tag pointer with the JavaScript object.
napi_check_object_type_tag() can then be used to compare the tag that was attached to the
object with one owned by the addon to ensure that the object has the right type.
If the object already has an associated type tag, this API will return napi_invalid_arg.
Source§fn check_object_type_tag(&self, tag: &NapiTypeTag) -> NapiResult<bool>
fn check_object_type_tag(&self, tag: &NapiTypeTag) -> NapiResult<bool>
Compares the pointer given as type_tag with any that can be found on js_object. If no tag
is found on js_object or, if a tag is found but it does not match type_tag, then result is
set to false. If a tag is found and it matches type_tag, then result is set to true.
impl Copy for JsDate
Auto Trait Implementations§
impl Freeze for JsDate
impl RefUnwindSafe for JsDate
impl !Send for JsDate
impl !Sync for JsDate
impl Unpin for JsDate
impl UnwindSafe for JsDate
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