pub struct Conout { /* private fields */ }
Expand description
Represents the output side of the tty/console terminal.
This is a singleton that aquires a lock to access the console (similiar to Stdin). It should be used to access the tty/terminal to avoid conflicts and other issues.
Implementations§
Source§impl Conout
impl Conout
Sourcepub fn lock<'a>(&self) -> ConsoleOutLock<'a> ⓘ
pub fn lock<'a>(&self) -> ConsoleOutLock<'a> ⓘ
Locks the output console and returns a guard.
Lock is released when the guard is dropped.
Sourcepub fn try_lock<'a>(&self) -> Option<ConsoleOutLock<'a>>
pub fn try_lock<'a>(&self) -> Option<ConsoleOutLock<'a>>
Tries to lock the output console and returns Some(guard) if it could or None if it could not. If the lock is already held by another thread then it will return None. Underlying lock is a ReentrantMutex from parking lot so will be fine to use on the same thread.
Lock is released when the guard is dropped.
Trait Implementations§
Source§impl ConsoleWrite for Conout
impl ConsoleWrite for Conout
Source§impl Write for Conout
impl Write for Conout
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Writes a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flushes this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations§
impl Freeze for Conout
impl !RefUnwindSafe for Conout
impl Send for Conout
impl Sync for Conout
impl Unpin for Conout
impl !UnwindSafe for Conout
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