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, s: &str) -> Option<Tag<'a, Self>> { ... }
fn convert_tag(&mut self, s: &'a str) -> Option<Tag<'a, Self>> { ... }
fn convert_item(&mut self, item: Item<'a>) -> ItemC<'a, Self> { ... }
fn convert_line(&mut self, items: Vec<Item<'a>>) -> Vec<ItemC<'a, Self>> { ... }
fn convert_ast(
&mut self,
ast: Vec<Vec<Item<'a>>>
) -> Vec<Vec<ItemC<'a, Self>>> { ... }
}Expand description
Trait for convert a raw tag string to Tag type.
Each generator has it own tag convertor, because different backend(show the final output) supports different kind of tags.
This Trait has three assoc type:
- Color: for foreground or background color
- Modifier: for style modifier(like bold, italic, etc.)
- Custom: for custom tag
The Generator with this convertor C will received a series of Item<Tag
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.
Only if this call fails, a convertor try to parse the raw tag string to a built-in tag. So the custom tag always have higher priority.
Provided Methods
fn parse_built_in_tag(&mut self, s: &str) -> Option<Tag<'a, Self>>
fn parse_built_in_tag(&mut self, s: &str) -> Option<Tag<'a, Self>>
Parse string to a builtin tag type.
fn convert_tag(&mut self, s: &'a str) -> Option<Tag<'a, Self>>
fn convert_tag(&mut self, s: &'a str) -> Option<Tag<'a, Self>>
convert the tag string to Tag type
fn convert_item(&mut self, item: Item<'a>) -> ItemC<'a, Self>
fn convert_item(&mut self, item: Item<'a>) -> ItemC<'a, Self>
Convert item with raw tag string to item with Tag type.
It will filtered out all tags that fail to parse.
Convert a line of items with raw tag string to items with Tag type.
It will filtered out all tags that fail to parse.
Implementors
sourceimpl<'a, P> TagConvertor<'a> for ANSITermTagConvertor<P> where
P: CustomTagParser<Output = Style>,
Available on crate feature ansi only.
impl<'a, P> TagConvertor<'a> for ANSITermTagConvertor<P> where
P: CustomTagParser<Output = Style>,
ansi only.sourceimpl<'a, P> TagConvertor<'a> for TuiTagConvertor<P> where
P: CustomTagParser<Output = Style>,
Available on crate feature tui only.
impl<'a, P> TagConvertor<'a> for TuiTagConvertor<P> where
P: CustomTagParser<Output = Style>,
tui only.