pub struct ExtensionDispatcher { /* private fields */ }Expand description
Owns registered extensions and routes messages to them.
Maintains a type-name index for O(1) dispatch, a node-to-extension
map for event/command routing, and per-extension poison state for
panic isolation. Created via
ToddyAppBuilder::build_dispatcher.
Implementations§
Source§impl ExtensionDispatcher
impl ExtensionDispatcher
pub fn new(extensions: Vec<Box<dyn WidgetExtension>>) -> Self
Sourcepub fn clone_for_session(&self) -> Self
pub fn clone_for_session(&self) -> Self
Create a new dispatcher for a multiplexed session.
Calls WidgetExtension::new_instance() on each registered
extension to produce independent instances with isolated mutable
state. The type-name index is rebuilt from the new instances.
Panics if any extension has not implemented new_instance().
Sourcepub fn handles_type(&self, type_name: &str) -> bool
pub fn handles_type(&self, type_name: &str) -> bool
Check if a node type is handled by an extension.
Sourcepub fn prepare_all(
&mut self,
root: &TreeNode,
caches: &mut ExtensionCaches,
theme: &Theme,
)
pub fn prepare_all( &mut self, root: &TreeNode, caches: &mut ExtensionCaches, theme: &Theme, )
Called after Core::apply() on tree changes.
Sourcepub fn handle_event(
&mut self,
id: &str,
family: &str,
data: &Value,
caches: &mut ExtensionCaches,
) -> EventResult
pub fn handle_event( &mut self, id: &str, family: &str, data: &Value, caches: &mut ExtensionCaches, ) -> EventResult
Handle a Message::Event.
Sourcepub fn handle_command(
&mut self,
node_id: &str,
op: &str,
payload: &Value,
caches: &mut ExtensionCaches,
) -> Vec<OutgoingEvent>
pub fn handle_command( &mut self, node_id: &str, op: &str, payload: &Value, caches: &mut ExtensionCaches, ) -> Vec<OutgoingEvent>
Handle an ExtensionCommand.
Sourcepub fn init_all(&mut self, config: &Value)
pub fn init_all(&mut self, config: &Value)
Route configuration to extensions. config is the value of the
extension_config key from Settings – a JSON object keyed by
each extension’s config_key().
Sourcepub fn render<'a>(
&'a self,
node: &'a TreeNode,
env: &WidgetEnv<'a>,
) -> Option<Element<'a, Message>>
pub fn render<'a>( &'a self, node: &'a TreeNode, env: &WidgetEnv<'a>, ) -> Option<Element<'a, Message>>
Render an extension node. Returns None if no extension handles this type.
The caller must construct the WidgetEnv and pass it in. This avoids
a borrow-checker issue where a locally-constructed env would be dropped
before the returned Element (which borrows from the env).
Note: catch_unwind happens in the caller (widgets::render) because
the returned Element borrows from env and can’t be wrapped in a
closure. When a render panic is caught, the caller should call
record_render_panic to track consecutive failures.
Sourcepub fn record_render_panic(&self, type_name: &str) -> bool
pub fn record_render_panic(&self, type_name: &str) -> bool
Record a render panic for the extension that handles type_name.
Called by the catch_unwind wrapper in widgets::render (which has
only &self). Uses AtomicU32 so no &mut self is required.
Returns true if the extension has reached the poison threshold.
Sourcepub fn clear_poisoned(&mut self)
pub fn clear_poisoned(&mut self)
Reset all poisoned flags and render panic counters. Called on Snapshot.
Sourcepub fn cleanup_all(&mut self, caches: &mut ExtensionCaches)
pub fn cleanup_all(&mut self, caches: &mut ExtensionCaches)
Call cleanup() for every node currently tracked by the dispatcher.
Used before a full state reset (e.g. Reset message) so extensions get a chance to release per-node resources before their cache entries are wiped.
Sourcepub fn reset(&mut self, caches: &mut ExtensionCaches)
pub fn reset(&mut self, caches: &mut ExtensionCaches)
Full reset: call cleanup for all tracked nodes, clear the node map, clear extension caches, and reset poisoned state.
Extensions themselves (the registered trait objects) are preserved – only per-node runtime state is wiped.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExtensionDispatcher
impl !RefUnwindSafe for ExtensionDispatcher
impl Send for ExtensionDispatcher
impl Sync for ExtensionDispatcher
impl Unpin for ExtensionDispatcher
impl UnsafeUnpin for ExtensionDispatcher
impl !UnwindSafe for ExtensionDispatcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().