Skip to main content

OptionsTrait

Trait OptionsTrait 

Source
pub trait OptionsTrait {
    // Provided methods
    fn new() -> Self
       where Self: JsCast { ... }
    fn initialize(self) -> Self
       where Self: JsCast { ... }
    fn set(self, key: &str, value: JsValue) -> Self
       where Self: JsCast { ... }
}
Expand description

Trait for building JavaScript options objects, providing convenience methods to construct an empty object and set (optionally nested) values on it in a builder style.

Provided Methods§

Source

fn new() -> Self
where Self: JsCast,

“Construct a new Options.

Source

fn initialize(self) -> Self
where Self: JsCast,

Hook for initializing a freshly constructed options object. The default implementation returns self unchanged; implementors may override it to set default values.

Source

fn set(self, key: &str, value: JsValue) -> Self
where Self: JsCast,

Sets a value on the options object under the given key. Dot-separated keys (e.g. "a.b.c") traverse and create nested objects as needed. Returns self to allow builder-style chaining.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§