pub struct TerminalGuard<O: TerminalOps> { /* private fields */ }Expand description
Owns every terminal mode enabled by the frontend and restores them on drop.
Implementations§
Source§impl<O: TerminalOps> TerminalGuard<O>
impl<O: TerminalOps> TerminalGuard<O>
Sourcepub fn enter(ops: O) -> Result<Self>
pub fn enter(ops: O) -> Result<Self>
Enable all terminal modes, rolling back any successfully enabled prefix if a later operation fails.
Sourcepub fn restore(&mut self) -> Result<()>
pub fn restore(&mut self) -> Result<()>
Restore every active mode in reverse order. Restoration is best-effort: all operations are attempted and the first error is returned.
Sourcepub fn with_restored<T>(
&mut self,
action: impl FnOnce() -> Result<T>,
) -> Result<T>
pub fn with_restored<T>( &mut self, action: impl FnOnce() -> Result<T>, ) -> Result<T>
Temporarily restore the terminal around an external interactive action, then reacquire all modes even when that action returns an error.
Trait Implementations§
Source§impl<O: TerminalOps> Drop for TerminalGuard<O>
impl<O: TerminalOps> Drop for TerminalGuard<O>
Auto Trait Implementations§
impl<O> Freeze for TerminalGuard<O>where
O: Freeze,
impl<O> RefUnwindSafe for TerminalGuard<O>where
O: RefUnwindSafe,
impl<O> Send for TerminalGuard<O>where
O: Send,
impl<O> Sync for TerminalGuard<O>where
O: Sync,
impl<O> Unpin for TerminalGuard<O>where
O: Unpin,
impl<O> UnsafeUnpin for TerminalGuard<O>where
O: UnsafeUnpin,
impl<O> UnwindSafe for TerminalGuard<O>where
O: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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