script_bindings::inheritance

Trait Castable

Source
pub trait Castable:
    IDLInterface
    + DomObject
    + Sized {
    // Provided methods
    fn is<T>(&self) -> bool
       where T: DerivedFrom<Self> { ... }
    fn upcast<T>(&self) -> &T
       where T: Castable,
             Self: DerivedFrom<T> { ... }
    fn downcast<T>(&self) -> Option<&T>
       where T: DerivedFrom<Self> { ... }
}
Expand description

A trait to hold the cast functions of IDL interfaces that either derive or are derived from other interfaces.

Provided Methods§

Source

fn is<T>(&self) -> bool
where T: DerivedFrom<Self>,

Check whether a DOM object implements one of its deriving interfaces.

Source

fn upcast<T>(&self) -> &T
where T: Castable, Self: DerivedFrom<T>,

Cast a DOM object upwards to one of the interfaces it derives from.

Source

fn downcast<T>(&self) -> Option<&T>
where T: DerivedFrom<Self>,

Cast a DOM object downwards to one of the interfaces it might implement.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

impl Castable for Attr

impl Castable for Blob

impl Castable for Comment

impl Castable for CSSRule

impl Castable for DOMRect

impl Castable for Element

impl Castable for Event

impl Castable for File

impl Castable for Node

impl Castable for Range

impl Castable for Text

impl Castable for UIEvent

impl Castable for VTTCue

impl Castable for XRLayer

impl Castable for XRPose

impl Castable for XRSpace

impl Castable for Window

impl Castable for Worker