pub trait TagConvertor<'a> {
    type Color;
    type Modifier;
    type Custom;

    fn parse_color(&mut self, s: &str) -> Option<Self::Color>;
    fn parse_modifier(&mut self, s: &str) -> Option<Self::Modifier>;
    fn parse_custom_tag(&mut self, s: &str) -> Option<Self::Custom>;

    fn parse_built_in_tag(
        &mut self,
        ty: &str,
        value: &str
    ) -> Option<Tag<'a, Self>> { ... } fn convert_tag(&mut self, s: LSpan<'a>) -> Option<Tag<'a, Self>> { ... } fn convert_item(
        &mut self,
        item: Item<'a>
    ) -> Result<ItemC<'a, Self>, LSpan<'a>> { ... } fn convert_line(
        &mut self,
        items: Vec<Item<'a>>
    ) -> Result<Vec<ItemC<'a, Self>>, LSpan<'a>> { ... } fn convert(
        &mut self,
        ast: Vec<Vec<Item<'a>>>
    ) -> Result<Vec<Vec<ItemC<'a, Self>>>, LSpan<'a>> { ... } }
Expand description

Trait for convert a raw tag string to tag type.

Each generator has it own tag generator, because different backend(show the final output) supports different kind of tags.

So this tag generator should raise a error if there are unsupported tags in source code.

Required Associated Types

Color type for foreground and background typed tag.

Modifier type for modifier typed tag.

Custom tag type. Usually is the final type represent a style, can be converted from Color and Modifier.

Required Methods

Parse string to color type.

Parse string to modifier type.

Parse string to custom type, will be only called when a tag string isn’t a valid and acceptable builtin tag.

Provided Methods

Parse string to a builtin tag type.

convert the tag string to Tag type

Convert item with raw tag string to item with Tag type.

Convert a line of items with raw tag string to items with Tag type.

Convert all item with raw tag string of a ast into items with Tag type.

Implementors