[][src]Struct binjs::meta::export::TypeDeanonymizer

pub struct TypeDeanonymizer { /* fields omitted */ }

A tool designed to replace all anonymous types in a specification of the language by explicitly named types.

Consider the following mini-specifications for JSON:

interface Value {
    attribute (Object or String or Number or Array or Boolean)? value;
}
interface Object {
    attribute FrozenArray<Property> properties;
}
interface Property {
    attribute DOMString name;
    attribute Value value;
}
interface Array {
    attribute FrozenArray<Value?> items;
}
// ... Skipping definitions of String, Number, Boolean

The deanonymizer will rewrite them as follows:

interface Value { // Deanonymized optional sum
    attribute OptionalObjectOrStringOrNumberOrArrayOrBoolean value;
}
interface Object { // Deanonymized list
    attribute ListOfProperty properties;
}
interface Property { // No change
    attribute DOMString name;
    attribute Value value;
}
interface Array { // Deanonymized list of options
    attribute ListOfOptionalValue items;
}
// ... Skipping definitions of String, Number, Boolean

typedef ObjectOrStringOrNumberOrArrayOrBoolean? OptionalObjectOrStringOrNumberOrArrayOrBoolean;
typedef (Object
         or String
         or Number
         or Array
         or Boolean)
         ObjectOrStringOrNumberOrArrayOrBoolean;
typedef FrozenArray<Property> ListOfProperty;
typedef FrozenArray<OptionalValue> ListOfOptionalValue;
typedef Value? Optionalvalue;

This deanonymization lets us cleanly define intermediate data structures and/or parsers implementing the webidl specification.

Methods

impl TypeDeanonymizer[src]

pub fn new(spec: &Spec) -> TypeDeanonymizer[src]

Create an empty TypeDeanonymizer.

pub fn supersums(
    &self
) -> &HashMap<NodeName, HashSet<NodeName, RandomState>, RandomState>
[src]

pub fn into_spec(self, options: SpecOptions) -> Spec[src]

Convert into a new specification.

pub fn get_node_name(&self, name: &str) -> Option<NodeName>[src]

If name is the name of a (deanonymized) type, return the corresponding type.

Auto Trait Implementations

impl !RefUnwindSafe for TypeDeanonymizer

impl !Send for TypeDeanonymizer

impl !Sync for TypeDeanonymizer

impl Unpin for TypeDeanonymizer

impl UnwindSafe for TypeDeanonymizer

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]