ViewPathTracker

Trait ViewPathTracker 

Source
pub trait ViewPathTracker {
    // Required methods
    fn environment(&mut self) -> &mut Environment;
    fn push_id(&mut self, id: ViewId);
    fn pop_id(&mut self);
    fn view_path(&mut self) -> &[ViewId];

    // Provided method
    fn with_id<R>(&mut self, id: ViewId, f: impl FnOnce(&mut Self) -> R) -> R { ... }
}
Expand description

A tracker for view paths, used in View::build and View::rebuild. These paths are used for routing messages in View::message.

Each View is expected to be implemented for one logical context type, and this context may be used to store auxiliary data. For example, this context could be used to store a mapping from the id of widget to view path, to enable event routing.

Required Methods§

Source

fn environment(&mut self) -> &mut Environment

Access the Environment associated with this context.

I hope that we can remove the “context” generic entirely, and so this is here on a temporary basis.

Source

fn push_id(&mut self, id: ViewId)

Add id to the end of current view path

Source

fn pop_id(&mut self)

Remove the most recently pushed id from the current view path

Source

fn view_path(&mut self) -> &[ViewId]

The path to the current view in the view tree

Provided Methods§

Source

fn with_id<R>(&mut self, id: ViewId, f: impl FnOnce(&mut Self) -> R) -> R

Run f in a context with id pushed to the current view path

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§