[−][src]Struct binjs::meta::import::Importer
Methods
impl Importer
[src]
pub fn import<'a>(
sources: impl IntoIterator<Item = &'a str>
) -> Result<SpecBuilder, Err<(&'a str, ErrorKind)>>
[src]
sources: impl IntoIterator<Item = &'a str>
) -> Result<SpecBuilder, Err<(&'a str, ErrorKind)>>
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Downcast for T where
T: Any,
[src]
T: Any,
fn into_any(self: Box<T>) -> Box<dyn Any + 'static>
[src]
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
[src]
fn as_any(&self) -> &(dyn Any + 'static)
[src]
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,