pub trait Presenter {
// Required method
fn present<'async_trait>(
self,
command: Pin<Box<dyn Future<Output = CommandResult> + Send>>,
) -> Pin<Box<dyn Future<Output = CommandResult> + 'async_trait>>
where Self: 'async_trait;
}Expand description
Output port for rendering command output
A Presenter wraps command execution and controls the output lifecycle. The framework
constructs a presenter with its dependencies (such as an EventReceiver and rendering
configuration), then calls present with the command future. The presenter runs the
command, optionally consuming events from its receiver, and returns the command’s result.
present takes self by value because presentation is a one-shot operation. Each presenter
is constructed once, used once, and consumed. This encodes the “call once” invariant in the
type system and avoids interior mutability for resources like EventReceiver that require
exclusive access for reading.
The trait does not require Send or Sync because the presenter lives on the main task
and is never shared across threads.
§Examples
use clawless::presenter::{Presenter, TerminalPresenter};
let presenter = TerminalPresenter::builder().receiver(receiver).build();
presenter.present(Box::pin(command_future)).await?;Required Methods§
Sourcefn present<'async_trait>(
self,
command: Pin<Box<dyn Future<Output = CommandResult> + Send>>,
) -> Pin<Box<dyn Future<Output = CommandResult> + 'async_trait>>where
Self: 'async_trait,
fn present<'async_trait>(
self,
command: Pin<Box<dyn Future<Output = CommandResult> + Send>>,
) -> Pin<Box<dyn Future<Output = CommandResult> + 'async_trait>>where
Self: 'async_trait,
Presents the output of a command
Runs the given command future to completion and returns its result. Implementations may
consume events from their EventReceiver concurrently with command execution to render
output in real time.
The command future is boxed and pinned because the concrete future type varies by call
site. The future is Send because commands execute on Tokio’s multi-threaded runtime.
§Errors
Returns the command’s error if the command fails. Implementations propagate the
command’s CommandResult without modification.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".