Struct MarkupParser

Source
pub struct MarkupParser<B: Backend> {
    pub path: String,
    pub failed: bool,
    pub error: Option<String>,
    pub root: Option<Rc<RefCell<MarkupElement>>>,
    pub storage: Option<Rc<RefCell<RendererStorage<B>>>>,
    pub current: i32,
    pub indexed_elements: Vec<MarkupElement>,
    pub contexts: Vec<(String, Vec<MarkupElement>)>,
    pub state: HashMap<String, String>,
    pub actions: ActionsStorage,
    pub global_styles: StylesStorage,
    /* private fields */
}
Expand description

To use specific features you can use the macro:

  • #[cfg(feature = “test”)] also you can negate something:
  • #[cfg(not(test))] To enable something only for test use:
  • #[cfg(test)] To allow make a struct printable for debug use:
  • #[derive(Debug)]

Fields§

§path: String§failed: bool§error: Option<String>§root: Option<Rc<RefCell<MarkupElement>>>§storage: Option<Rc<RefCell<RendererStorage<B>>>>§current: i32§indexed_elements: Vec<MarkupElement>§contexts: Vec<(String, Vec<MarkupElement>)>§state: HashMap<String, String>§actions: ActionsStorage§global_styles: StylesStorage

Implementations§

Source§

impl<B: Backend> MarkupParser<B>

Source

pub fn new( path: String, optional_storage: Option<RendererStorage<B>>, initial_state: Option<HashMap<String, String>>, ) -> MarkupParser<B>

Source

pub fn add_action( &mut self, name: &str, action: fn(HashMap<String, String>, Option<MarkupElement>) -> EventResponse, ) -> &mut Self

Source

pub fn render_ui(&mut self, frame: &mut Frame<'_, B>) -> Result<bool, String>

Render the current state of the tree

Source

pub fn add_context(&mut self, node: &MarkupElement)

Source

pub fn remove_context(&mut self, node: &MarkupElement)

Source

pub fn test_check(&self, backend: B) -> Result<(), Box<dyn Error>>

Source

pub fn ui_loop( &mut self, backend: B, on_event: impl Fn(KeyEvent, HashMap<String, String>) -> EventResponse, ) -> Result<(), Box<dyn Error>>

Starts a render loop. the loop receive a callback thar will return true if the loop must finish.

  • on_event: callback thar receive a key event.
Source

pub fn get_element(node: Option<Rc<RefCell<MarkupElement>>>) -> MarkupElement

Source

pub fn extract_element(node: &Rc<RefCell<MarkupElement>>) -> MarkupElement

Source

pub fn is_widget(node_name: &str) -> bool

Source

pub fn is_layout(node_name: &str) -> bool

Source

pub fn get_border(border_value: &str) -> Borders

Source

pub fn get_constraint(constraint: String) -> Constraint

Source

pub fn get_direction(node: &MarkupElement) -> Direction

Source

pub fn get_alignment(node: &MarkupElement) -> Alignment

Source

pub fn process_styles(node: MarkupElement) -> StylesStorage

Source

pub fn get_styles(node: &MarkupElement, focus: bool, active: bool) -> Style

Trait Implementations§

Source§

impl<B: Backend> Debug for MarkupParser<B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<B> Freeze for MarkupParser<B>

§

impl<B> !RefUnwindSafe for MarkupParser<B>

§

impl<B> !Send for MarkupParser<B>

§

impl<B> !Sync for MarkupParser<B>

§

impl<B> Unpin for MarkupParser<B>

§

impl<B> !UnwindSafe for MarkupParser<B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.