Struct rquickjs_core::Atom
source · pub struct Atom<'js> { /* private fields */ }
Expand description
An atom is value representing the name of a variable of an objects and can be created from any javascript value.
Representation
Atoms in quickjs are handled differently depending on what type of index the represent.
When the atom represents a number like index, like object[1]
the atom is just
a normal number.
However when the atom represents a string link index like object["foo"]
or object.foo
the atom represents a value in a hashmap.
Implementations§
source§impl<'js> Atom<'js>
impl<'js> Atom<'js>
sourcepub fn from_value(ctx: Ctx<'js>, val: &Value<'js>) -> Result<Atom<'js>>
pub fn from_value(ctx: Ctx<'js>, val: &Value<'js>) -> Result<Atom<'js>>
Create a atom from a javascript value.
sourcepub fn from_i32(ctx: Ctx<'js>, val: i32) -> Result<Atom<'js>>
pub fn from_i32(ctx: Ctx<'js>, val: i32) -> Result<Atom<'js>>
Create a atom from an i32 via value
sourcepub fn from_bool(ctx: Ctx<'js>, val: bool) -> Result<Atom<'js>>
pub fn from_bool(ctx: Ctx<'js>, val: bool) -> Result<Atom<'js>>
Create a atom from a bool via value
sourcepub fn from_f64(ctx: Ctx<'js>, val: f64) -> Result<Atom<'js>>
pub fn from_f64(ctx: Ctx<'js>, val: f64) -> Result<Atom<'js>>
Create a atom from a f64 via value
sourcepub fn from_str(ctx: Ctx<'js>, name: &str) -> Result<Atom<'js>>
pub fn from_str(ctx: Ctx<'js>, name: &str) -> Result<Atom<'js>>
Create a atom from a rust string
sourcepub fn to_js_string(&self) -> Result<String<'js>>
pub fn to_js_string(&self) -> Result<String<'js>>
Convert the atom to a javascript string .
Trait Implementations§
Auto Trait Implementations§
impl<'js> RefUnwindSafe for Atom<'js>
impl<'js> Send for Atom<'js>
impl<'js> !Sync for Atom<'js>
impl<'js> Unpin for Atom<'js>
impl<'js> !UnwindSafe for Atom<'js>
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