pub struct AsyncRunner { /* private fields */ }async only.Expand description
An asynchronous Crossterm event and rendering loop.
See the module documentation for the full picture. Construct one with
a RunnerConfig, then drive it with run (real terminal),
run_with_backend (caller-supplied backend, such as
HyperlinkBackend), or
run_with_events (caller-supplied backend and
event stream, for tests and hosts that own the terminal lifecycle).
Implementations§
Source§impl AsyncRunner
impl AsyncRunner
Sourcepub fn new(config: RunnerConfig) -> Self
pub fn new(config: RunnerConfig) -> Self
Create a runner without touching the terminal.
Sourcepub fn with_session_config(self, config: TerminalSessionConfig) -> Self
pub fn with_session_config(self, config: TerminalSessionConfig) -> Self
Override terminal lifecycle policy while retaining the async loop.
Sourcepub fn scrollback(&self) -> Scrollback
pub fn scrollback(&self) -> Scrollback
Return a handle for publishing content above a
ScreenMode::SplitFooter — see
Scrollback. Blocks queued while running in
ScreenMode::Alternate are discarded,
since there is no scrollback of the host’s to write into.
Sourcepub async fn run<S, V, U>(
&self,
theme: &Theme,
state: &mut S,
view: V,
update: U,
) -> Result<()>
pub async fn run<S, V, U>( &self, theme: &Theme, state: &mut S, view: V, update: U, ) -> Result<()>
Run on the real terminal until update returns UpdateResult::Exit.
Enters a TerminalSession (restored on return, including on error or
panic) and reads input from crossterm’s async
EventStream.
Sourcepub async fn run_with_backend<S, B, V, U>(
&self,
theme: &Theme,
backend: B,
state: &mut S,
view: V,
update: U,
) -> Result<()>where
B: Backend<Error = Error>,
V: FnMut(&S, u64) -> Element,
U: AsyncFnMut(&mut S, Signal) -> UpdateResult,
pub async fn run_with_backend<S, B, V, U>(
&self,
theme: &Theme,
backend: B,
state: &mut S,
view: V,
update: U,
) -> Result<()>where
B: Backend<Error = Error>,
V: FnMut(&S, u64) -> Element,
U: AsyncFnMut(&mut S, Signal) -> UpdateResult,
Run with a caller-provided backend, such as
HyperlinkBackend. Otherwise identical to
run: it owns the TerminalSession and the
EventStream.
Sourcepub async fn run_with_events<S, B, V, U, E, Er>(
&self,
terminal: &mut Terminal<B>,
theme: &Theme,
state: &mut S,
events: E,
view: V,
update: U,
) -> Result<(), Er>
pub async fn run_with_events<S, B, V, U, E, Er>( &self, terminal: &mut Terminal<B>, theme: &Theme, state: &mut S, events: E, view: V, update: U, ) -> Result<(), Er>
The core loop: caller-owned terminal and events, no terminal
lifecycle. This is what run builds on, and the seam tests
use to drive the runner against a
TestBackend with a scripted event
stream. Hosts that already own their terminal and event source (or want a
non-crossterm one) can call it directly.
The backend error and the event-stream error share one type Er, which
is the run’s error type: for the real terminal that is io::Error, but
leaving it generic lets an infallible backend
(TestBackend, whose error is
Infallible) pair with an infallible stream.
events yields already-translated tuika Events. An Err item ends
the run by propagating out; None (a finite stream running dry) stops
event delivery but leaves the tick timer running, so the loop still exits
only when update returns UpdateResult::Exit.
Auto Trait Implementations§
impl Freeze for AsyncRunner
impl RefUnwindSafe for AsyncRunner
impl Send for AsyncRunner
impl Sync for AsyncRunner
impl Unpin for AsyncRunner
impl UnsafeUnpin for AsyncRunner
impl UnwindSafe for AsyncRunner
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> 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