Skip to main content

Source

Trait Source 

pub trait Source {
    // Required methods
    fn key(&self) -> &str;
    fn prop(&mut self, name: &str) -> Option<Value>;
    fn event(&mut self, name: &str) -> Event;
    fn binding(&mut self, name: &str) -> Option<BoundValue>;
    fn children(&mut self, slot: &str) -> Vec<Box<dyn Widget>>;
    fn components(
        &mut self,
        slot: &str,
        read: &mut dyn FnMut(&mut dyn Source) -> Result<(), String>,
    ) -> Result<usize, String>;

    // Provided methods
    fn state(&mut self, name: &str) -> Option<Value> { ... }
    fn slot_kinds(&mut self, slot: &str) -> Vec<Option<String>> { ... }
    fn rows(&mut self, slot: &str) -> Option<Rc<RefCell<dyn RowSource>>> { ... }
}
Expand description

An instance of a component as its host gives it: the values of its props, its events and bindings as data, and its slots’ content.

Required Methods§

fn key(&self) -> &str

The instance’s stable key.

fn prop(&mut self, name: &str) -> Option<Value>

The value of the prop name, when the instance gives it.

fn event(&mut self, name: &str) -> Event

What the event name does: Event::None when the instance gives it nothing.

fn binding(&mut self, name: &str) -> Option<BoundValue>

The binding name, when the instance binds it.

fn children(&mut self, slot: &str) -> Vec<Box<dyn Widget>>

The views in the slot slot, built.

fn components( &mut self, slot: &str, read: &mut dyn FnMut(&mut dyn Source) -> Result<(), String>, ) -> Result<usize, String>

Each component in the slot slot, in order, read by read. Returns how many there were.

§Errors

What read returned, or the slot holds something other than a component.

Provided Methods§

fn state(&mut self, name: &str) -> Option<Value>

The widget state name to restore, when there is some.

fn slot_kinds(&mut self, slot: &str) -> Vec<Option<String>>

The component each child of the slot slot is an instance of, in order: None for a child that is a view of another kind.

fn rows(&mut self, slot: &str) -> Option<Rc<RefCell<dyn RowSource>>>

The rows of the slot slot when its host renders them only as they are shown (a loop over a collection of any length): the widget reads them from there rather than from Self::components.

Implementors§