[][src]Struct binjs::meta::import::Importer

pub struct Importer { /* fields omitted */ }

Methods

impl Importer[src]

pub fn import<'a>(
    sources: impl IntoIterator<Item = &'a str>
) -> Result<SpecBuilder, Err<(&'a str, ErrorKind)>>
[src]

Import a WebIDL spec into a SpecBuilder.

A WebIDL spec may consist in several files. Files are parsed in the order of sources. An extension file (e.g. es6-extended.webidl) MUST appear after the files it extends.

extern crate binjs_meta;
use binjs_meta::spec::SpecOptions;

let mut builder = binjs_meta::import::Importer::import(vec!["
   interface FooContents {
     attribute boolean value;
   };
   interface LazyFoo {
      [Lazy] attribute FooContents contents;
   };
   interface EagerFoo {
      attribute FooContents contents;
   };
"].into_iter()).expect("Could not parse");

let fake_root = builder.node_name("@@ROOT@@"); // Unused
let null = builder.node_name(""); // Used
let spec = builder.into_spec(SpecOptions {
    root: &fake_root,
    null: &null,
});

let name_eager = spec.get_node_name("EagerFoo")
    .expect("Missing name EagerFoo");
let name_lazy = spec.get_node_name("LazyFoo")
    .expect("Missing name LazyFoo");
let name_contents = spec.get_field_name("contents")
    .expect("Missing name contents");

{
    let interface_eager = spec.get_interface_by_name(&name_eager)
        .expect("Missing interface EagerFoo");
    let contents_field =
        interface_eager.get_field_by_name(&name_contents)
        .expect("Missing field contents");
    assert_eq!(contents_field.is_lazy(), false);
}

{
    let interface_lazy = spec.get_interface_by_name(&name_lazy)
        .expect("Missing interface LazyFoo");
    let contents_field =
        interface_lazy.get_field_by_name(&name_contents)
        .expect("Missing field contents");
    assert_eq!(contents_field.is_lazy(), true);
}

Auto Trait Implementations

impl !RefUnwindSafe for Importer

impl !Send for Importer

impl !Sync for Importer

impl Unpin for Importer

impl UnwindSafe for Importer

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]