Trait tui_markup::generator::TagConvertor
source · [−]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
Required Methods
fn parse_color(&mut self, s: &str) -> Option<Self::Color>
fn parse_color(&mut self, s: &str) -> Option<Self::Color>
Parse string to color type.
fn parse_modifier(&mut self, s: &str) -> Option<Self::Modifier>
fn parse_modifier(&mut self, s: &str) -> Option<Self::Modifier>
Parse string to modifier type.
fn parse_custom_tag(&mut self, s: &str) -> Option<Self::Custom>
fn parse_custom_tag(&mut self, s: &str) -> Option<Self::Custom>
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.
fn convert_tag(&mut self, s: LSpan<'a>) -> Option<Tag<'a, Self>>
fn convert_tag(&mut self, s: LSpan<'a>) -> Option<Tag<'a, Self>>
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.