pub struct EventReader { /* private fields */ }Expand description
Blocking event pump that forwards terminal events to the async AppEvent channel.
EventReader must run on a dedicated std::thread — it calls
blocking_send and crossterm’s blocking poll, which would stall a tokio
worker thread.
§Examples
use std::time::Duration;
use tokio::sync::mpsc;
use zeph_tui::EventReader;
let (tx, rx) = mpsc::channel(64);
let reader = EventReader::new(tx, Duration::from_millis(250));
std::thread::spawn(|| reader.run());Implementations§
Source§impl EventReader
impl EventReader
Sourcepub fn new(tx: Sender<AppEvent>, tick_rate: Duration) -> Self
pub fn new(tx: Sender<AppEvent>, tick_rate: Duration) -> Self
Create a new reader that sends events to tx at up to tick_rate cadence.
§Examples
use std::time::Duration;
use tokio::sync::mpsc;
use zeph_tui::EventReader;
let (tx, _rx) = mpsc::channel(64);
let reader = EventReader::new(tx, Duration::from_millis(250));Sourcepub fn run(self)
pub fn run(self)
Start the blocking event loop using the default CrosstermEventSource.
Must be called from a dedicated std::thread, not a tokio worker.
Returns when the AppEvent channel receiver is dropped.
Sourcepub fn run_with_source(self, source: impl EventSource)
pub fn run_with_source(self, source: impl EventSource)
Start the blocking event loop with a custom EventSource.
This variant exists primarily for testing with mock sources.
Returns when the source returns None or the channel is closed.
Auto Trait Implementations§
impl Freeze for EventReader
impl RefUnwindSafe for EventReader
impl Send for EventReader
impl Sync for EventReader
impl Unpin for EventReader
impl UnsafeUnpin for EventReader
impl UnwindSafe for EventReader
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
Mutably borrows from an owned value. Read more
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<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>
Converts
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>
Converts
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request