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§
Required Methods§
Sourcefn size(&self) -> Result<(u16, u16), Self::Error>
fn size(&self) -> Result<(u16, u16), Self::Error>
Query current terminal dimensions (columns, rows).
Sourcefn set_features(&mut self, features: BackendFeatures) -> Result<(), Self::Error>
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.
Sourcefn poll_event(&mut self, timeout: Duration) -> Result<bool, Self::Error>
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.
Sourcefn read_event(&mut self) -> Result<Option<Event>, Self::Error>
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.
A prior poll_event readiness result is a hint, not a guarantee:
implementations may return Ok(None) even immediately after a true
poll (e.g. the pending input was discarded by the parser, or, on
Windows, console readiness was spurious — see frankentui#95).
Implementations must not park indefinitely when no event is actually
pending; callers must treat Ok(None) as “nothing decodable right
now” and return to their poll loop.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".