Skip to main content

AtomTable

Struct AtomTable 

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

The atoms one runtime has interned.

Per runtime rather than per process because the reference’s are too: a JSAtom is only meaningful to the runtime that made it, which is why every accessor takes a JSContext * or a JSRuntime * and why mixing two runtimes’ atoms is undefined by construction.

Implementations§

Source§

impl AtomTable

Source

pub fn new() -> AtomTable

A table holding only the pinned atoms.

Source

pub fn text(&self, atom: Atom) -> Option<&str>

The text atom addresses, or None for JS_ATOM_NULL and out-of-range atoms.

Source

pub fn intern(&mut self, text: &str) -> Atom

Intern text, answering the atom that addresses it.

Never answers ATOM_NULL: this engine has no “out of memory” atom, and a caller that compares against JS_ATOM_NULL to detect failure would otherwise see a spurious one.

Source

pub fn len(&self) -> usize

How many atoms are interned, for the memory-usage report.

Source

pub fn is_empty(&self) -> bool

Whether nothing but the pinned atoms is interned.

Never true — the constructor fills the pinned prefix — but a len without it trips clippy::len_without_is_empty, and the answer is honest about what it counts.

Trait Implementations§

Source§

impl Default for AtomTable

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Forget for AtomTable

§

impl Freeze for AtomTable

§

impl Move for AtomTable

§

impl RefUnwindSafe for AtomTable

§

impl Send for AtomTable
where RawVecInner: Send, RawTable<(String, u32)>: Send,

§

impl Sync for AtomTable
where RawVecInner: Sync, RawTable<(String, u32)>: Sync,

§

impl Unpin for AtomTable
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for AtomTable

§

impl UnwindSafe for AtomTable
where RawVecInner: UnwindSafe, HashMap<String, u32>: UnwindSafe,

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> 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, 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.