Skip to main content

BackendEventSource

Trait BackendEventSource 

Source
pub trait BackendEventSource {
    type Error: Debug + Display;

    // Required methods
    fn size(&self) -> Result<(u16, u16), Self::Error>;
    fn set_features(
        &mut self,
        features: BackendFeatures,
    ) -> Result<(), Self::Error>;
    fn poll_event(&mut self, timeout: Duration) -> Result<bool, Self::Error>;
    fn read_event(&mut self) -> Result<Option<Event>, Self::Error>;
}
Expand description

Event source abstraction: terminal size queries, feature toggles, and event I/O.

This is the input half of the backend boundary. The runtime polls this for canonical Event values without knowing whether they come from crossterm, raw Unix reads, or DOM events.

Required Associated Types§

Source

type Error: Debug + Display

Platform-specific error type.

Required Methods§

Source

fn size(&self) -> Result<(u16, u16), Self::Error>

Query current terminal dimensions (columns, rows).

Source

fn set_features(&mut self, features: BackendFeatures) -> Result<(), Self::Error>

Enable or disable terminal features (mouse, paste, focus, kitty keyboard).

Backends must track current state and only emit escape sequences for changes.

Source

fn poll_event(&mut self, timeout: Duration) -> Result<bool, Self::Error>

Poll for an available event, returning true if one is ready.

Must not block longer than timeout. Returns Ok(false) on timeout.

Source

fn read_event(&mut self) -> Result<Option<Event>, Self::Error>

Read the next available event, or None if none is ready.

Call after poll_event returns true, or speculatively.

Implementors§