Skip to main content

TargetedEvent

Trait TargetedEvent 

Source
pub trait TargetedEvent: Event {
    // Required method
    fn target(&self) -> &str;
}
Expand description

Marker trait for events that target a specific component.

Events implementing this trait have a target field that specifies which component should handle the event. This enables EventBus::subscribe_targeted() to automatically filter events by target.

§Design Note

The kernel uses &str for target identifiers (mechanism), not ComponentId (which is a policy-level type). Modules convert their identifiers to &str when interacting with the kernel API.

§Example

use reovim_kernel::api::v1::*;

#[derive(Debug)]
struct PluginTextInput {
    target: &'static str,
    c: char,
}

impl Event for PluginTextInput {}

impl TargetedEvent for PluginTextInput {
    fn target(&self) -> &str {
        self.target
    }
}

Required Methods§

Source

fn target(&self) -> &str

Get the target component identifier for this event.

Used by EventBus::subscribe_targeted() to filter events.

Implementors§