pub trait Transport {
type Backend: Backend;
// Required methods
fn terminal_mut(&mut self) -> &mut Terminal<Self::Backend>;
fn poll(&mut self, timeout: Duration) -> Result<Option<RawEvent>>;
// Provided methods
fn finish(self) -> Result<()>
where Self: Sized { ... }
fn write_passthrough(&mut self, _bytes: &[u8]) -> Result<()> { ... }
fn client_term(&self) -> Option<&str> { ... }
}Expand description
Bridge between the event loop and whatever terminal it talks to.
Lifecycle: a Transport is constructed in whatever mode it needs
(raw mode, alternate screen, SSH channel attached), then passed by
mutable reference to crate::runtime::run_loop. When the loop
exits, the owning code calls Transport::finish to tear down.
The transport owns the Terminal rather than just a raw backend
because ratatui’s Terminal<B> requires B: Backend, which does
not hold for &mut B. Having the transport expose
terminal_mut() keeps the runtime generic without hitting that
trait-bound wall.
Required Associated Types§
Required Methods§
Sourcefn terminal_mut(&mut self) -> &mut Terminal<Self::Backend>
fn terminal_mut(&mut self) -> &mut Terminal<Self::Backend>
Mutable access to the owned ratatui Terminal so the runtime
can drive draw.
Provided Methods§
Sourcefn finish(self) -> Result<()>where
Self: Sized,
fn finish(self) -> Result<()>where
Self: Sized,
Restore the terminal to its pre-TUI state. The default impl is a no-op so test transports do not have to implement it.
§Errors
Returns Err if teardown fails, e.g. writing the
“leave alternate screen” escape to a closed stdout.
Sourcefn write_passthrough(&mut self, _bytes: &[u8]) -> Result<()>
fn write_passthrough(&mut self, _bytes: &[u8]) -> Result<()>
Forward a raw byte sequence to the same stream the backend writes to, bypassing ratatui’s cell grid. Used for terminal escape sequences that ratatui can’t model directly — kitty graphics APC bytes, future sixel, etc. The default impl silently drops the bytes so transports that don’t speak that dialect (or test doubles) don’t need an override.
§Errors
Returns Err only if the underlying stream write fails.
Sourcefn client_term(&self) -> Option<&str>
fn client_term(&self) -> Option<&str>
Terminal type the client claims to be, in OpenSSH-style
xterm-256color form. The local transport reads $TERM; the
SSH transport returns whatever the peer sent in pty-req.
Returns None when the transport cannot tell.
Capability detection (kitty graphics, true-colour, etc.) should consult this rather than the daemon’s own environment, which is whatever the host running the daemon happened to have.