ComponentAccessor

Trait ComponentAccessor 

Source
pub trait ComponentAccessor: Debug {
    // Required methods
    fn name(&self) -> String;
    fn area(&self) -> Option<Rect>;
    fn set_area(&mut self, area: Rect);
    fn is_active(&self) -> bool;
    fn set_active(&mut self, active: bool);
    fn register_action_handler(&mut self, tx: UnboundedSender<Action>);
    fn send(&self, action: &str);
    fn send_action(&self, action: Action);
    fn as_active(self) -> Self
       where Self: Sized;
    fn get_children(&mut self) -> &mut BTreeMap<String, Box<dyn Component>>;
}
Expand description

A trait that provides access to the basic properties of a component.

This trait is used to manage a component’s name, area, active state, and children.

Required Methods§

Source

fn name(&self) -> String

Returns the name of the component.

Source

fn area(&self) -> Option<Rect>

Returns the area (Rect) of the component, if it has been set.

Source

fn set_area(&mut self, area: Rect)

Sets the area (Rect) for the component.

Source

fn is_active(&self) -> bool

Returns the active state of the component.

Source

fn set_active(&mut self, active: bool)

Sets the active state of the component.

Source

fn register_action_handler(&mut self, tx: UnboundedSender<Action>)

Registers an action handler that can send Actions for processing.

Source

fn send(&self, action: &str)

Sends a string message through the action handler bus.

Source

fn send_action(&self, action: Action)

Sends an Action through the action handler bus.

Source

fn as_active(self) -> Self
where Self: Sized,

Sets the component as active on initialization (builder-pattern).

Source

fn get_children(&mut self) -> &mut BTreeMap<String, Box<dyn Component>>

Gets all child components. This is necessary if the component has children, as it will be used by other functions to have knowledge of the children.

Implementors§