Struct Val

Source
pub struct Val { /* private fields */ }
Expand description

A wrapper around a javascript handle

Implementations§

Source§

impl Val

Source

pub const fn global_this() -> Val

Returns the globalThis object

Source

pub fn get<T: Into<Val>>(&self, prop: T) -> Val

Gets the property prop

Examples found in repository?
examples/dom.rs (line 15)
3fn main() {
4    let document = Val::global("document");
5    let elem = document.call("createElement", &argv!["BUTTON"]);
6    elem.set("textContent", Val::from("Click"));
7    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
8    elem.call(
9        "addEventListener",
10        &argv![
11            "click",
12            Val::make_fn(|ev| {
13                let console = Console::get();
14                console.call("clear", &[]);
15                console.log(&[ev[0].get("clientX")]);
16                println!("client x: {}", ev[0].get("clientX").as_::<i32>());
17                println!("hello from Rust");
18                Val::undefined()
19            })
20        ],
21    );
22    body.call("appendChild", &argv![elem]);
23}
More examples
Hide additional examples
examples/audio.rs (line 17)
3fn main() {
4    #[allow(non_snake_case)]
5    let mut AudioContext = Val::global("AudioContext");
6    if !AudioContext.as_::<bool>() {
7        println!("No global AudioContext, trying webkitAudioContext");
8        AudioContext = Val::global("webkitAudioContext");
9    }
10
11    println!("Got an AudioContext");
12    let context = AudioContext.new(&[]);
13    let oscillator = context.call("createOscillator", &[]);
14
15    println!("Configuring oscillator");
16    oscillator.set("type", "triangle");
17    oscillator.get("frequency").set::<_, f64>("value", 261.63); // Middle C
18
19    let document = Val::global("document");
20    let elem = document.call("createElement", &argv!["BUTTON"]);
21    elem.set("textContent", "Click");
22    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
23    elem.call(
24        "addEventListener",
25        &argv![
26            "click",
27            Val::make_fn(move |_| {
28                println!("Playing");
29                oscillator.call("connect", &argv![context.get("destination")]);
30                oscillator.call("start", &argv![0]);
31                println!("All done!");
32                Val::undefined()
33            })
34        ],
35    );
36    body.call("appendChild", &argv![elem]);
37}
Source

pub fn global(name: &str) -> Val

Gets a global object by name

Examples found in repository?
examples/bind.rs (line 24)
22    fn new(x: i32, y: i32) -> Self {
23        Self {
24            val: Val::global("MyJsClass").new(&argv![x, y]),
25        }
26    }
More examples
Hide additional examples
examples/dom.rs (line 4)
3fn main() {
4    let document = Val::global("document");
5    let elem = document.call("createElement", &argv!["BUTTON"]);
6    elem.set("textContent", Val::from("Click"));
7    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
8    elem.call(
9        "addEventListener",
10        &argv![
11            "click",
12            Val::make_fn(|ev| {
13                let console = Console::get();
14                console.call("clear", &[]);
15                console.log(&[ev[0].get("clientX")]);
16                println!("client x: {}", ev[0].get("clientX").as_::<i32>());
17                println!("hello from Rust");
18                Val::undefined()
19            })
20        ],
21    );
22    body.call("appendChild", &argv![elem]);
23}
examples/audio.rs (line 5)
3fn main() {
4    #[allow(non_snake_case)]
5    let mut AudioContext = Val::global("AudioContext");
6    if !AudioContext.as_::<bool>() {
7        println!("No global AudioContext, trying webkitAudioContext");
8        AudioContext = Val::global("webkitAudioContext");
9    }
10
11    println!("Got an AudioContext");
12    let context = AudioContext.new(&[]);
13    let oscillator = context.call("createOscillator", &[]);
14
15    println!("Configuring oscillator");
16    oscillator.set("type", "triangle");
17    oscillator.get("frequency").set::<_, f64>("value", 261.63); // Middle C
18
19    let document = Val::global("document");
20    let elem = document.call("createElement", &argv!["BUTTON"]);
21    elem.set("textContent", "Click");
22    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
23    elem.call(
24        "addEventListener",
25        &argv![
26            "click",
27            Val::make_fn(move |_| {
28                println!("Playing");
29                oscillator.call("connect", &argv![context.get("destination")]);
30                oscillator.call("start", &argv![0]);
31                println!("All done!");
32                Val::undefined()
33            })
34        ],
35    );
36    body.call("appendChild", &argv![elem]);
37}
Source

pub const fn null() -> Val

Gets a js null Val

Source

pub const fn undefined() -> Val

Gets a js undefined Val

Examples found in repository?
examples/dom.rs (line 18)
3fn main() {
4    let document = Val::global("document");
5    let elem = document.call("createElement", &argv!["BUTTON"]);
6    elem.set("textContent", Val::from("Click"));
7    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
8    elem.call(
9        "addEventListener",
10        &argv![
11            "click",
12            Val::make_fn(|ev| {
13                let console = Console::get();
14                console.call("clear", &[]);
15                console.log(&[ev[0].get("clientX")]);
16                println!("client x: {}", ev[0].get("clientX").as_::<i32>());
17                println!("hello from Rust");
18                Val::undefined()
19            })
20        ],
21    );
22    body.call("appendChild", &argv![elem]);
23}
More examples
Hide additional examples
examples/audio.rs (line 32)
3fn main() {
4    #[allow(non_snake_case)]
5    let mut AudioContext = Val::global("AudioContext");
6    if !AudioContext.as_::<bool>() {
7        println!("No global AudioContext, trying webkitAudioContext");
8        AudioContext = Val::global("webkitAudioContext");
9    }
10
11    println!("Got an AudioContext");
12    let context = AudioContext.new(&[]);
13    let oscillator = context.call("createOscillator", &[]);
14
15    println!("Configuring oscillator");
16    oscillator.set("type", "triangle");
17    oscillator.get("frequency").set::<_, f64>("value", 261.63); // Middle C
18
19    let document = Val::global("document");
20    let elem = document.call("createElement", &argv!["BUTTON"]);
21    elem.set("textContent", "Click");
22    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
23    elem.call(
24        "addEventListener",
25        &argv![
26            "click",
27            Val::make_fn(move |_| {
28                println!("Playing");
29                oscillator.call("connect", &argv![context.get("destination")]);
30                oscillator.call("start", &argv![0]);
31                println!("All done!");
32                Val::undefined()
33            })
34        ],
35    );
36    body.call("appendChild", &argv![elem]);
37}
Source

pub fn object() -> Val

Gets a new js object

Source

pub fn array() -> Val

Gets a new js array

Source

pub fn set<K: Into<Val>, V: Into<Val>>(&self, prop: K, val: V)

Set the underlying js object property prop to val

Examples found in repository?
examples/dom.rs (line 6)
3fn main() {
4    let document = Val::global("document");
5    let elem = document.call("createElement", &argv!["BUTTON"]);
6    elem.set("textContent", Val::from("Click"));
7    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
8    elem.call(
9        "addEventListener",
10        &argv![
11            "click",
12            Val::make_fn(|ev| {
13                let console = Console::get();
14                console.call("clear", &[]);
15                console.log(&[ev[0].get("clientX")]);
16                println!("client x: {}", ev[0].get("clientX").as_::<i32>());
17                println!("hello from Rust");
18                Val::undefined()
19            })
20        ],
21    );
22    body.call("appendChild", &argv![elem]);
23}
More examples
Hide additional examples
examples/audio.rs (line 16)
3fn main() {
4    #[allow(non_snake_case)]
5    let mut AudioContext = Val::global("AudioContext");
6    if !AudioContext.as_::<bool>() {
7        println!("No global AudioContext, trying webkitAudioContext");
8        AudioContext = Val::global("webkitAudioContext");
9    }
10
11    println!("Got an AudioContext");
12    let context = AudioContext.new(&[]);
13    let oscillator = context.call("createOscillator", &[]);
14
15    println!("Configuring oscillator");
16    oscillator.set("type", "triangle");
17    oscillator.get("frequency").set::<_, f64>("value", 261.63); // Middle C
18
19    let document = Val::global("document");
20    let elem = document.call("createElement", &argv!["BUTTON"]);
21    elem.set("textContent", "Click");
22    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
23    elem.call(
24        "addEventListener",
25        &argv![
26            "click",
27            Val::make_fn(move |_| {
28                println!("Playing");
29                oscillator.call("connect", &argv![context.get("destination")]);
30                oscillator.call("start", &argv![0]);
31                println!("All done!");
32                Val::undefined()
33            })
34        ],
35    );
36    body.call("appendChild", &argv![elem]);
37}
Source

pub fn has<T: Into<Val>>(&self, prop: T) -> bool

Checks whether a property prop exists

Source

pub fn has_own_property(&self, prop: &str) -> bool

Checks whether a non-inherited property prop exists

Source

pub fn type_of(&self) -> String

Gets the typeof the underlying js object

Source

pub fn at<T: Into<Val>>(&self, idx: T) -> Val

Gets the element at index idx. Assumes the underlying js type is indexable

Examples found in repository?
examples/dom.rs (line 7)
3fn main() {
4    let document = Val::global("document");
5    let elem = document.call("createElement", &argv!["BUTTON"]);
6    elem.set("textContent", Val::from("Click"));
7    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
8    elem.call(
9        "addEventListener",
10        &argv![
11            "click",
12            Val::make_fn(|ev| {
13                let console = Console::get();
14                console.call("clear", &[]);
15                console.log(&[ev[0].get("clientX")]);
16                println!("client x: {}", ev[0].get("clientX").as_::<i32>());
17                println!("hello from Rust");
18                Val::undefined()
19            })
20        ],
21    );
22    body.call("appendChild", &argv![elem]);
23}
More examples
Hide additional examples
examples/audio.rs (line 22)
3fn main() {
4    #[allow(non_snake_case)]
5    let mut AudioContext = Val::global("AudioContext");
6    if !AudioContext.as_::<bool>() {
7        println!("No global AudioContext, trying webkitAudioContext");
8        AudioContext = Val::global("webkitAudioContext");
9    }
10
11    println!("Got an AudioContext");
12    let context = AudioContext.new(&[]);
13    let oscillator = context.call("createOscillator", &[]);
14
15    println!("Configuring oscillator");
16    oscillator.set("type", "triangle");
17    oscillator.get("frequency").set::<_, f64>("value", 261.63); // Middle C
18
19    let document = Val::global("document");
20    let elem = document.call("createElement", &argv!["BUTTON"]);
21    elem.set("textContent", "Click");
22    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
23    elem.call(
24        "addEventListener",
25        &argv![
26            "click",
27            Val::make_fn(move |_| {
28                println!("Playing");
29                oscillator.call("connect", &argv![context.get("destination")]);
30                oscillator.call("start", &argv![0]);
31                println!("All done!");
32                Val::undefined()
33            })
34        ],
35    );
36    body.call("appendChild", &argv![elem]);
37}
Source

pub fn to_vec<V: FromVal>(&self) -> Vec<V>

Converts the underlying js array to a Vec of V

Source

pub fn call(&self, f: &str, args: &[Val]) -> Val

Calls the method f with args, can return an undefined js value

Examples found in repository?
examples/bind.rs (line 28)
27    fn print(&self) {
28        self.val.call("print", &[]);
29    }
30}
31
32impl FromVal for MyJsClass {
33    fn from_val(v: &Val) -> Self {
34        MyJsClass { val: v.clone() }
35    }
36    fn take_ownership(v: Handle) -> Self {
37        Self::from_val(&Val::take_ownership(v))
38    }
39    fn as_handle(&self) -> Handle {
40        self.val.as_handle()
41    }
42}
43
44impl Deref for MyJsClass {
45    type Target = Val;
46
47    fn deref(&self) -> &Self::Target {
48        &self.val
49    }
50}
51
52impl DerefMut for MyJsClass {
53    fn deref_mut(&mut self) -> &mut Self::Target {
54        &mut self.val
55    }
56}
57
58impl From<MyJsClass> for Val {
59    fn from(s: MyJsClass) -> Val {
60        let handle = s.as_handle();
61        std::mem::forget(s);
62        Val::take_ownership(handle)
63    }
64}
65
66fn main() {
67    MyJsClass::define();
68    let c = MyJsClass::new(5, 6);
69    c.call("print", &[]);
70    let b = eval!(
71        r#"
72        let b = new MyJsClass(6, 7);
73        b.print();
74        b
75    "#
76    );
77    let a = b.as_::<MyJsClass>();
78    a.print();
79    let console = Console::get();
80    console.log(&[a.into()]);
81}
More examples
Hide additional examples
examples/dom.rs (line 5)
3fn main() {
4    let document = Val::global("document");
5    let elem = document.call("createElement", &argv!["BUTTON"]);
6    elem.set("textContent", Val::from("Click"));
7    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
8    elem.call(
9        "addEventListener",
10        &argv![
11            "click",
12            Val::make_fn(|ev| {
13                let console = Console::get();
14                console.call("clear", &[]);
15                console.log(&[ev[0].get("clientX")]);
16                println!("client x: {}", ev[0].get("clientX").as_::<i32>());
17                println!("hello from Rust");
18                Val::undefined()
19            })
20        ],
21    );
22    body.call("appendChild", &argv![elem]);
23}
examples/audio.rs (line 13)
3fn main() {
4    #[allow(non_snake_case)]
5    let mut AudioContext = Val::global("AudioContext");
6    if !AudioContext.as_::<bool>() {
7        println!("No global AudioContext, trying webkitAudioContext");
8        AudioContext = Val::global("webkitAudioContext");
9    }
10
11    println!("Got an AudioContext");
12    let context = AudioContext.new(&[]);
13    let oscillator = context.call("createOscillator", &[]);
14
15    println!("Configuring oscillator");
16    oscillator.set("type", "triangle");
17    oscillator.get("frequency").set::<_, f64>("value", 261.63); // Middle C
18
19    let document = Val::global("document");
20    let elem = document.call("createElement", &argv!["BUTTON"]);
21    elem.set("textContent", "Click");
22    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
23    elem.call(
24        "addEventListener",
25        &argv![
26            "click",
27            Val::make_fn(move |_| {
28                println!("Playing");
29                oscillator.call("connect", &argv![context.get("destination")]);
30                oscillator.call("start", &argv![0]);
31                println!("All done!");
32                Val::undefined()
33            })
34        ],
35    );
36    body.call("appendChild", &argv![elem]);
37}
Source

pub fn new(&self, args: &[Val]) -> Val

Calls the object’s constructor with args constructing a new object

Examples found in repository?
examples/bind.rs (line 24)
22    fn new(x: i32, y: i32) -> Self {
23        Self {
24            val: Val::global("MyJsClass").new(&argv![x, y]),
25        }
26    }
More examples
Hide additional examples
examples/audio.rs (line 12)
3fn main() {
4    #[allow(non_snake_case)]
5    let mut AudioContext = Val::global("AudioContext");
6    if !AudioContext.as_::<bool>() {
7        println!("No global AudioContext, trying webkitAudioContext");
8        AudioContext = Val::global("webkitAudioContext");
9    }
10
11    println!("Got an AudioContext");
12    let context = AudioContext.new(&[]);
13    let oscillator = context.call("createOscillator", &[]);
14
15    println!("Configuring oscillator");
16    oscillator.set("type", "triangle");
17    oscillator.get("frequency").set::<_, f64>("value", 261.63); // Middle C
18
19    let document = Val::global("document");
20    let elem = document.call("createElement", &argv!["BUTTON"]);
21    elem.set("textContent", "Click");
22    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
23    elem.call(
24        "addEventListener",
25        &argv![
26            "click",
27            Val::make_fn(move |_| {
28                println!("Playing");
29                oscillator.call("connect", &argv![context.get("destination")]);
30                oscillator.call("start", &argv![0]);
31                println!("All done!");
32                Val::undefined()
33            })
34        ],
35    );
36    body.call("appendChild", &argv![elem]);
37}
Source

pub fn invoke(&self, args: &[Val]) -> Val

Invokes the function object with args, can return an undefined js value

Source

pub fn make_fn_raw(f: fn(Handle, Handle) -> Handle, data: Handle) -> Val

Creates js function from a function pointer and returns its handle wrapped in a Val object

Source

pub fn make_fn<F: FnMut(&[Val]) -> Val>(cb: F) -> Val

Creates a js function from a Rust closure and returns a Val

Examples found in repository?
examples/dom.rs (lines 12-19)
3fn main() {
4    let document = Val::global("document");
5    let elem = document.call("createElement", &argv!["BUTTON"]);
6    elem.set("textContent", Val::from("Click"));
7    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
8    elem.call(
9        "addEventListener",
10        &argv![
11            "click",
12            Val::make_fn(|ev| {
13                let console = Console::get();
14                console.call("clear", &[]);
15                console.log(&[ev[0].get("clientX")]);
16                println!("client x: {}", ev[0].get("clientX").as_::<i32>());
17                println!("hello from Rust");
18                Val::undefined()
19            })
20        ],
21    );
22    body.call("appendChild", &argv![elem]);
23}
More examples
Hide additional examples
examples/audio.rs (lines 27-33)
3fn main() {
4    #[allow(non_snake_case)]
5    let mut AudioContext = Val::global("AudioContext");
6    if !AudioContext.as_::<bool>() {
7        println!("No global AudioContext, trying webkitAudioContext");
8        AudioContext = Val::global("webkitAudioContext");
9    }
10
11    println!("Got an AudioContext");
12    let context = AudioContext.new(&[]);
13    let oscillator = context.call("createOscillator", &[]);
14
15    println!("Configuring oscillator");
16    oscillator.set("type", "triangle");
17    oscillator.get("frequency").set::<_, f64>("value", 261.63); // Middle C
18
19    let document = Val::global("document");
20    let elem = document.call("createElement", &argv!["BUTTON"]);
21    elem.set("textContent", "Click");
22    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
23    elem.call(
24        "addEventListener",
25        &argv![
26            "click",
27            Val::make_fn(move |_| {
28                println!("Playing");
29                oscillator.call("connect", &argv![context.get("destination")]);
30                oscillator.call("start", &argv![0]);
31                println!("All done!");
32                Val::undefined()
33            })
34        ],
35    );
36    body.call("appendChild", &argv![elem]);
37}
Source

pub fn await_(&self) -> Val

Awaits the invoked function object

Source

pub fn delete(v: Val)

Decrements the refcount of the underlying handle

Source

pub fn throw(v: Val) -> !

Throws a js object represented by Val

Source

pub fn instanceof(&self, v: Val) -> bool

Checks whether this Val is an instanceof v

Source

pub fn is_number(&self) -> bool

Source

pub fn is_string(&self) -> bool

Source

pub fn is_null(&self) -> bool

Source

pub fn is_undefined(&self) -> bool

Source

pub fn is_error(&self) -> bool

Source

pub fn is_function(&self) -> bool

Source

pub fn as_<T>(&self) -> T
where T: FromVal,

Examples found in repository?
examples/bind.rs (line 77)
66fn main() {
67    MyJsClass::define();
68    let c = MyJsClass::new(5, 6);
69    c.call("print", &[]);
70    let b = eval!(
71        r#"
72        let b = new MyJsClass(6, 7);
73        b.print();
74        b
75    "#
76    );
77    let a = b.as_::<MyJsClass>();
78    a.print();
79    let console = Console::get();
80    console.log(&[a.into()]);
81}
More examples
Hide additional examples
examples/dom.rs (line 16)
3fn main() {
4    let document = Val::global("document");
5    let elem = document.call("createElement", &argv!["BUTTON"]);
6    elem.set("textContent", Val::from("Click"));
7    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
8    elem.call(
9        "addEventListener",
10        &argv![
11            "click",
12            Val::make_fn(|ev| {
13                let console = Console::get();
14                console.call("clear", &[]);
15                console.log(&[ev[0].get("clientX")]);
16                println!("client x: {}", ev[0].get("clientX").as_::<i32>());
17                println!("hello from Rust");
18                Val::undefined()
19            })
20        ],
21    );
22    body.call("appendChild", &argv![elem]);
23}
examples/audio.rs (line 6)
3fn main() {
4    #[allow(non_snake_case)]
5    let mut AudioContext = Val::global("AudioContext");
6    if !AudioContext.as_::<bool>() {
7        println!("No global AudioContext, trying webkitAudioContext");
8        AudioContext = Val::global("webkitAudioContext");
9    }
10
11    println!("Got an AudioContext");
12    let context = AudioContext.new(&[]);
13    let oscillator = context.call("createOscillator", &[]);
14
15    println!("Configuring oscillator");
16    oscillator.set("type", "triangle");
17    oscillator.get("frequency").set::<_, f64>("value", 261.63); // Middle C
18
19    let document = Val::global("document");
20    let elem = document.call("createElement", &argv!["BUTTON"]);
21    elem.set("textContent", "Click");
22    let body = document.call("getElementsByTagName", &argv!["body"]).at(0);
23    elem.call(
24        "addEventListener",
25        &argv![
26            "click",
27            Val::make_fn(move |_| {
28                println!("Playing");
29                oscillator.call("connect", &argv![context.get("destination")]);
30                oscillator.call("start", &argv![0]);
31                println!("All done!");
32                Val::undefined()
33            })
34        ],
35    );
36    body.call("appendChild", &argv![elem]);
37}

Trait Implementations§

Source§

impl AsMut<Val> for Val

Source§

fn as_mut(&mut self) -> &mut Val

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<Val> for Val

Source§

fn as_ref(&self) -> &Val

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Val

Source§

fn clone(&self) -> Val

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Val

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Val

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl From<&String> for Val

Source§

fn from(s: &String) -> Self

Converts to this type from the input type.
Source§

impl From<&Val> for Val

Source§

fn from(v: &Val) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for Val

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<()> for Val

Source§

fn from(_: ()) -> Self

Converts to this type from the input type.
Source§

impl From<Console> for Val

Source§

fn from(val: Console) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Val

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Val

Source§

fn from(v: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Val

Source§

fn from(v: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Val

Source§

fn from(v: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Val

Source§

fn from(v: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Val

Source§

fn from(v: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Val

Source§

fn from(v: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for Val

Source§

fn from(v: i8) -> Self

Converts to this type from the input type.
Source§

impl From<isize> for Val

Source§

fn from(v: isize) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Val

Source§

fn from(v: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Val

Source§

fn from(v: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Val

Source§

fn from(v: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Val

Source§

fn from(v: u8) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for Val

Source§

fn from(v: usize) -> Self

Converts to this type from the input type.
Source§

impl FromVal for Val

Source§

fn from_val(v: &Val) -> Self

Creates a Val object from another
Source§

fn take_ownership(v: Handle) -> Self

Takes the ownership of a handle
Source§

fn as_handle(&self) -> Handle

Returns the raw js handle
Source§

impl Not for Val

Source§

type Output = bool

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl PartialEq for Val

Source§

fn eq(&self, other: &Val) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Val

Source§

fn partial_cmp(&self, other: &Val) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations§

§

impl Freeze for Val

§

impl RefUnwindSafe for Val

§

impl Send for Val

§

impl Sync for Val

§

impl Unpin for Val

§

impl UnwindSafe for Val

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.