pub struct HostClasses { /* private fields */ }Expand description
The host’s class registry: the JS_NewClass / JS_SetClassProto half of the class API.
One per realm, because a class id is only meaningful within the runtime that handed it
out — the reference keeps one array per JSRuntime for the same reason, so a Date and
a host class cannot collide.
Implementations§
Source§impl HostClasses
impl HostClasses
Sourcepub fn register(&mut self, def: ClassDef) -> ClassId
pub fn register(&mut self, def: ClassDef) -> ClassId
Allocate an id and register def under it (JS_NewClassID + JS_NewClass).
Sourcepub fn define(&mut self, id: ClassId, def: ClassDef) -> bool
pub fn define(&mut self, id: ClassId, def: ClassDef) -> bool
Register def under an id the caller already has (JS_NewClass).
The C API splits “get an id” from “register a class” because a module may be initialised lazily; registering twice under one id replaces the definition, and an object created under the old one keeps the old behaviour, since it carries its own reference.
Sourcepub fn set_proto(&mut self, id: ClassId, proto: Gc<JsObject>)
pub fn set_proto(&mut self, id: ClassId, proto: Gc<JsObject>)
Install the prototype instances of id inherit (JS_SetClassProto).
Trait Implementations§
Source§impl Default for HostClasses
impl Default for HostClasses
Source§fn default() -> HostClasses
fn default() -> HostClasses
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for HostClasses
impl !Send for HostClasses
impl !Sync for HostClasses
impl !UnwindSafe for HostClasses
impl Forget for HostClasses
impl Freeze for HostClasses
impl Move for HostClasses
impl Unpin for HostClasses
impl UnsafeUnpin for HostClasseswhere
*const LeafNode<ClassId, Rc<ClassDef>> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(ClassId, Rc<ClassDef>)>>: UnsafeUnpin,
*const LeafNode<ClassId, Gc<JsObject>> is !null: UnsafeUnpin,
PhantomData<Box<(ClassId, Gc<JsObject>)>>: UnsafeUnpin,
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