pub struct DescriptorAccessorBuilder<T: NapiValueT, R: NapiValueT> {
    pub utf8name: Option<String>,
    pub name: napi_value,
    pub getter: Option<Box<dyn FnMut(JsObject) -> NapiResult<R> + 'static>>,
    pub setter: Option<Box<dyn FnMut(JsObject, [T; 1]) -> NapiResult<()> + 'static>>,
    pub attributes: NapiPropertyAttributes,
}
Expand description

The DescriptorBuild for accessor. NB: there seems no way to reclaim the napi_property_descriptor.data, so it is leaked.

Fields

utf8name: Option<String>name: napi_valuegetter: Option<Box<dyn FnMut(JsObject) -> NapiResult<R> + 'static>>setter: Option<Box<dyn FnMut(JsObject, [T; 1]) -> NapiResult<()> + 'static>>attributes: NapiPropertyAttributes

Implementations

Optional string describing the key for the property, encoded as UTF8. One of utf8name or name must be provided for the property.

Optional napi_value that points to a JavaScript string or symbol to be used as the key for the property. One of utf8name or name must be provided for the property.

A function to call when a get access of the property is performed. If this is passed in, set value and method to NULL (since these members won’t be used). The given function is called implicitly by the runtime when the property is accessed from JavaScript code (or if a get on the property is performed using a Node-API call). napi_callback provides more details.

A function to call when a set access of the property is performed. If this is passed in, set value and method to NULL (since these members won’t be used). The given function is called implicitly by the runtime when the property is set from JavaScript code (or if a set on the property is performed using a Node-API call). napi_callback provides more details.

The attributes associated with the particular property. See napi_property_attributes.

build finale NapiPropertyDescriptor

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.