Trait UnicodeProvider

Source
pub trait UnicodeProvider {
    // Required method
    fn get_char(&self, theme: UnicodeTheme) -> char;

    // Provided method
    fn get_str(&self, theme: UnicodeTheme) -> &'static str { ... }
}
Expand description

Unicode character provider trait

This trait defines the interface for all Unicode symbol types in the library. It provides a consistent way to get character representations across different themes and ensures type safety.

§Examples

use unicode_rs::prelude::*;

// All symbol enums implement UnicodeProvider
let check = Symbol::Check.get_char(UnicodeTheme::Rich);
let arrow = Arrow::Right.get_char(UnicodeTheme::Rich);
let git_status = GitStatus::Modified.get_char(UnicodeTheme::Rich);

println!("Status: {} {} {}", check, arrow, git_status);

§Implementation Notes

  • All implementations should handle all theme variants
  • ASCII fallbacks should be provided for Minimal theme
  • The trait is object-safe and can be used with dynamic dispatch

Required Methods§

Source

fn get_char(&self, theme: UnicodeTheme) -> char

Get character for the given theme

Returns the appropriate Unicode character for the specified theme. Implementations should provide meaningful fallbacks for all themes.

§Arguments
  • theme - The Unicode theme to use for character selection
§Examples
use unicode_rs::prelude::*;

let symbol = Symbol::Check;
assert_eq!(symbol.get_char(UnicodeTheme::Minimal), 'v');
assert_eq!(symbol.get_char(UnicodeTheme::Rich), '✓');

Provided Methods§

Source

fn get_str(&self, theme: UnicodeTheme) -> &'static str

Get string representation for the given theme

Implementors§