pub struct ProgramHandle<M: Model> { /* private fields */ }Expand description
Handle to a running program.
Returned by Program::start() to allow external interaction with the
running TUI program. This is particularly useful for SSH applications
where events need to be injected from outside the program.
§Example
ⓘ
use bubbletea::{Program, Message};
let handle = Program::new(MyModel::default())
.with_custom_io()
.start();
// Send a message to the running program
handle.send(MyMessage::DoSomething);
// Wait for the program to finish
let final_model = handle.wait()?;Implementations§
Source§impl<M: Model> ProgramHandle<M>
impl<M: Model> ProgramHandle<M>
Sourcepub fn send<T: Into<Message>>(&self, msg: T) -> bool
pub fn send<T: Into<Message>>(&self, msg: T) -> bool
Send a message to the running program.
This queues the message for processing in the program’s event loop.
Returns true if the message was sent successfully, false if the
program has already exited.
Sourcepub fn quit(&self)
pub fn quit(&self)
Request the program to quit.
This sends a QuitMsg to the program’s event loop.
Sourcepub fn wait(self) -> Result<M>
pub fn wait(self) -> Result<M>
Wait for the program to finish and return the final model state.
This blocks until the program exits.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if the program is still running.
Auto Trait Implementations§
impl<M> Freeze for ProgramHandle<M>
impl<M> !RefUnwindSafe for ProgramHandle<M>
impl<M> Send for ProgramHandle<M>
impl<M> Sync for ProgramHandle<M>
impl<M> Unpin for ProgramHandle<M>
impl<M> !UnwindSafe for ProgramHandle<M>
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