Trait Translator

Source
pub trait Translator {
    type Source: 'static + Flavor;
    type Target: 'static + Flavor;

    // Required methods
    fn translate_package(
        &self,
        _: <Self::Source as Flavor>::Package,
    ) -> Result<<Self::Target as Flavor>::Package>;
    fn translate_type(
        &self,
        diag: &mut Diagnostics,
        _: <Self::Source as Flavor>::Type,
    ) -> Result<<Self::Target as Flavor>::Type>;
    fn translate_field(
        &self,
        diag: &mut Diagnostics,
        _: <Self::Source as Flavor>::Field,
    ) -> Result<<Self::Target as Flavor>::Field>;
    fn translate_endpoint(
        &self,
        diag: &mut Diagnostics,
        _: <Self::Source as Flavor>::Endpoint,
    ) -> Result<<Self::Target as Flavor>::Endpoint>;
    fn translate_local_name(
        &self,
        diag: &mut Diagnostics,
        reg: RpReg,
        name: <Self::Source as Flavor>::Name,
    ) -> Result<<Self::Target as Flavor>::Name>;
    fn translate_enum_type(
        &self,
        diag: &mut Diagnostics,
        enum_type: <Self::Source as Flavor>::EnumType,
    ) -> Result<<Self::Target as Flavor>::EnumType>;

    // Provided method
    fn visit(
        &self,
        _: &mut Diagnostics,
        _: &<Self::Source as Flavor>::Name,
    ) -> Result<()> { ... }
}
Expand description

Translator trait from one flavor to another.

Required Associated Types§

Source

type Source: 'static + Flavor

Source

type Target: 'static + Flavor

Required Methods§

Source

fn translate_package( &self, _: <Self::Source as Flavor>::Package, ) -> Result<<Self::Target as Flavor>::Package>

Translate the given package from one flavor to another.

Source

fn translate_type( &self, diag: &mut Diagnostics, _: <Self::Source as Flavor>::Type, ) -> Result<<Self::Target as Flavor>::Type>

Translate the given type from one flavor to another.

Source

fn translate_field( &self, diag: &mut Diagnostics, _: <Self::Source as Flavor>::Field, ) -> Result<<Self::Target as Flavor>::Field>

Translate the given field from one flavor to another.

Source

fn translate_endpoint( &self, diag: &mut Diagnostics, _: <Self::Source as Flavor>::Endpoint, ) -> Result<<Self::Target as Flavor>::Endpoint>

Translate the given endpoint from one flavor to another.

Source

fn translate_local_name( &self, diag: &mut Diagnostics, reg: RpReg, name: <Self::Source as Flavor>::Name, ) -> Result<<Self::Target as Flavor>::Name>

Translate a local declaration name.

Source

fn translate_enum_type( &self, diag: &mut Diagnostics, enum_type: <Self::Source as Flavor>::EnumType, ) -> Result<<Self::Target as Flavor>::EnumType>

Enum type to translate.

Provided Methods§

Source

fn visit( &self, _: &mut Diagnostics, _: &<Self::Source as Flavor>::Name, ) -> Result<()>

Indicate that the given name has been visited.

Implementors§