pub struct AsyncKeySender { /* private fields */ }Expand description
Non-blocking KeySender decorator — moves the blocking tmux
round-trip off the caller’s thread. send/scroll enqueue onto an
unbounded channel and return immediately (sub-microsecond); a single
background thread drains the channel in FIFO order and replays each
job against the wrapped sender.
Why (#386): the TUI forwards each keystroke inline on its
render/event loop (app::run). A per-key tmux send-keys blocks
that loop ~3ms, and a keystroke that lands while the loop is mid
capture-pane / refresh waits behind it — perceptible input lag.
Handing the send to a background thread frees the loop to observe the
next key and redraw. The channel is FIFO and single-consumer, so the
pane still receives keys in the exact order and form the inline path
produced — no batching, no reordering, so the #374 forwarding
contract (Esc / Ctrl+C / arrows) is untouched.
Inner-sender contract: the wrapped KeySender must signal failures
by returning Err (which the worker swallows and moves on, matching
the inline path’s best-effort let _ = send(...)), not by panicking.
TmuxKeySender honours this — its tmux round-trip returns Err on
any failure and never unwraps — so the worker thread is durable for
the life of the app.
Implementations§
Trait Implementations§
Source§impl Drop for AsyncKeySender
impl Drop for AsyncKeySender
Source§impl KeySender for AsyncKeySender
impl KeySender for AsyncKeySender
fn send(&self, session: &str, key: &EncodedKey) -> Result<()>
Source§fn scroll(&self, session: &str, direction: ScrollDirection) -> Result<()>
fn scroll(&self, session: &str, direction: ScrollDirection) -> Result<()>
tmux attach + wheel does — wheel-up auto-enters
copy-mode, subsequent ticks scroll the buffer. Wheel-down on a
pane not in copy-mode is a no-op (tmux’s own behaviour).Auto Trait Implementations§
impl !Freeze for AsyncKeySender
impl RefUnwindSafe for AsyncKeySender
impl Send for AsyncKeySender
impl Sync for AsyncKeySender
impl Unpin for AsyncKeySender
impl UnsafeUnpin for AsyncKeySender
impl UnwindSafe for AsyncKeySender
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> 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>
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 more