pub struct Terminal { /* private fields */ }
Expand description
An application’s handle to the terminal.
Implementations§
source§impl Terminal
impl Terminal
sourcepub async fn run<F, A, T>(start: F) -> Result<T, Error>where
F: FnOnce(Terminal) -> A + Send + 'static,
A: Future<Output = T> + Send + 'static,
T: Send + 'static,
pub async fn run<F, A, T>(start: F) -> Result<T, Error>where F: FnOnce(Terminal) -> A + Send + 'static, A: Future<Output = T> + Send + 'static, T: Send + 'static,
Runs the terminal application with the default settings, i.e. minumum screen is 80x25, 20ms for frame rendering interval, and 20ms for event polling from the OS.
Gives the application a handle to the terminal. When the given start function finishes, the application’s execution stops as well.
After that start
’s future returns, terminal services such as screen
handle and events handle are not guaranteed to be available. One would
prefer spawning tasks that use the terminal handle by joining them, and
not detaching.
Returns an AlreadyRunning
error if there is already an instance of
terminal services executing. In other words, one should not call
this function again if another call did not finish yet, otherwise it
will panic.
Beware! If the given start
future returns a Result
, then run
will
return a double Result
!!
sourcepub async fn lock_now<'terminal>(
&'terminal mut self
) -> Result<TerminalGuard<'terminal>, ServicesOff>
pub async fn lock_now<'terminal>( &'terminal mut self ) -> Result<TerminalGuard<'terminal>, ServicesOff>
Locks the terminal immediately (except it has to wait for the lock to be available). A locked terminal handle is returned, on which an application can write to the screen or get the most recent event.
Screen is locked, event channel is locked.
sourcepub async fn listen<'terminal>(
&'terminal mut self
) -> Result<TerminalGuard<'terminal>, ServicesOff>
pub async fn listen<'terminal>( &'terminal mut self ) -> Result<TerminalGuard<'terminal>, ServicesOff>
Listens for an event and only finishes when an event arrives. A locked terminal handle is returned, on which an application can write to the screen or get the most recent event, which will be present.
Screen is locked, event channel is locked.
sourcepub fn clear_event(&mut self)
pub fn clear_event(&mut self)
Clears the event channel. After this call, the current event is marked as read and it will no longer be available.
sourcepub async fn wait_user<'terminal>(
&'terminal mut self,
delay: Duration
) -> Result<TerminalGuard<'terminal>, ServicesOff>
pub async fn wait_user<'terminal>( &'terminal mut self, delay: Duration ) -> Result<TerminalGuard<'terminal>, ServicesOff>
Waits for user input before continuing, but waits for some given time
(delay
). Clears any previous event after waiting and listening to a
new event.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Terminal
impl Send for Terminal
impl Sync for Terminal
impl Unpin for Terminal
impl !UnwindSafe for Terminal
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.