pub struct Atom<'js> { /* private fields */ }
Expand description
A QuickJS Atom.
In QuickJS atoms are similar to interned string but with additional uses. A symbol for instance is just an atom.
§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>, Error>
pub fn from_value(ctx: Ctx<'js>, val: &Value<'js>) -> Result<Atom<'js>, Error>
Create an atom from a JavaScript value.
sourcepub fn from_i32(ctx: Ctx<'js>, val: i32) -> Result<Atom<'js>, Error>
pub fn from_i32(ctx: Ctx<'js>, val: i32) -> Result<Atom<'js>, Error>
Create an atom from an i32
via value
sourcepub fn from_bool(ctx: Ctx<'js>, val: bool) -> Result<Atom<'js>, Error>
pub fn from_bool(ctx: Ctx<'js>, val: bool) -> Result<Atom<'js>, Error>
Create an atom from a bool
via value
sourcepub fn from_f64(ctx: Ctx<'js>, val: f64) -> Result<Atom<'js>, Error>
pub fn from_f64(ctx: Ctx<'js>, val: f64) -> Result<Atom<'js>, Error>
Create an atom from a f64
via value
sourcepub fn from_str(ctx: Ctx<'js>, name: &str) -> Result<Atom<'js>, Error>
pub fn from_str(ctx: Ctx<'js>, name: &str) -> Result<Atom<'js>, Error>
Create an atom from a Rust string
sourcepub fn from_predefined(ctx: Ctx<'js>, predefined: PredefinedAtom) -> Atom<'js>
pub fn from_predefined(ctx: Ctx<'js>, predefined: PredefinedAtom) -> Atom<'js>
Create an atom from a predefined atom.
sourcepub fn to_js_string(&self) -> Result<String<'js>, Error>
pub fn to_js_string(&self) -> Result<String<'js>, Error>
Convert the atom to a JavaScript string.
Trait Implementations§
source§impl<'js> PartialEq for Atom<'js>
impl<'js> PartialEq for Atom<'js>
impl<'js> Eq for Atom<'js>
Auto Trait Implementations§
impl<'js> Freeze for Atom<'js>
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
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more