Skip to main content

Val

Enum Val 

Source
pub enum Val {
Show 14 variants Undefined, Null, Bool(bool), Num(f64), Str(Rc<str>), Bytes(Rc<[u8]>), Array(Vec<Val>), Object(Vec<(Rc<str>, Val)>), Fn(u32, Rc<str>), Arena(u32), Node(u32, u32), Promise(u32), Error(Rc<str>), Output(u32, u32),
}
Expand description

a javascript value

Variants§

§

Undefined

§

Null

§

Bool(bool)

§

Num(f64)

§

Str(Rc<str>)

§

Bytes(Rc<[u8]>)

§

Array(Vec<Val>)

§

Object(Vec<(Rc<str>, Val)>)

§

Fn(u32, Rc<str>)

§

Arena(u32)

§

Node(u32, u32)

§

Promise(u32)

§

Error(Rc<str>)

§

Output(u32, u32)

a buffer owned by the output registry: id, length of the content

Implementations§

Source§

impl Val

Source

pub fn str(s: &str) -> Val

Source

pub fn object(entries: Vec<(&str, Val)>) -> Val

Source

pub fn is_nullish(&self) -> bool

Source

pub fn get(&self, key: &str) -> &Val

Source

pub fn num(&self) -> f64

Source

pub fn u32(&self) -> u32

Source

pub fn as_str(&self) -> Option<&str>

Source

pub fn truthy(&self) -> bool

Source

pub fn ids(&self) -> Vec<u32>

a list of numbers (node ids)

Source

pub fn to_def(&self) -> HostDef

host definition (options, visitors): the functions are callbacks

Source

pub fn to_host(&self) -> HostValue

value returned by a callback

Source

pub fn to_plain(&self) -> Plain

Source

pub fn from_plain(plain: &Plain) -> Val

Source

pub fn from_host(value: &HostValue, arena: u32) -> Val

Source

pub fn encode(&self, out: &mut Vec<u8>)

encode the value at the end of a buffer

Source

pub fn decode(bytes: &[u8], pos: &mut usize) -> Val

decode a value. pos is moved after it

Trait Implementations§

Source§

impl Clone for Val

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 Default for Val

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl !Send for Val

§

impl !Sync for Val

§

impl Forget for Val

§

impl Freeze for Val

§

impl Move for Val

§

impl RefUnwindSafe for Val

§

impl Unpin for Val

§

impl UnsafeUnpin 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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.