pub struct TtyHandle { /* private fields */ }
Expand description

TTY handles represent a stream for the console.

Implementations§

source§

impl TtyHandle

source

pub fn new(loop: &Loop, fd: i32) -> Result<TtyHandle>

Initialize a new TTY stream with the given file descriptor. Usually the file descriptor will be:

0 = stdin 1 = stdout 2 = stderr

On Unix this function will determine the path of the fd of the terminal using ttyname_r(3), open it, and use it if the passed file descriptor refers to a TTY. This lets libuv put the tty in non-blocking mode without affecting other processes that share the tty.

This function is not thread safe on systems that don’t support ioctl TIOCGPTN or TIOCPTYGNAME, for instance OpenBSD and Solaris.

Note: If reopening the TTY fails, libuv falls back to blocking writes.

source

pub fn set_mode(&mut self, mode: TtyMode) -> Result<()>

Set the TTY using the specified terminal mode.

source

pub fn reset_mode() -> Result<()>

To be called when the program exits. Resets TTY settings to default values for the next process to take over.

This function is async signal-safe on Unix platforms but can fail with error code EBUSY if you call it when execution is inside uv_tty_set_mode().

source

pub fn get_winsize(&self) -> Result<(i32, i32)>

Gets the current Window size.

source

pub fn set_vterm_state(state: VTermState)

Controls whether console virtual terminal sequences are processed by libuv or console. Useful in particular for enabling ConEmu support of ANSI X3.64 and Xterm 256 colors. Otherwise Windows10 consoles are usually detected automatically.

This function is only meaningful on Windows systems. On Unix it is silently ignored.

source

pub fn get_vterm_state() -> Result<VTermState>

Get the current state of whether console virtual terminal sequences are handled by libuv or the console.

This function is not implemented on Unix, where it returns UV_ENOTSUP.

Trait Implementations§

source§

impl Clone for TtyHandle

source§

fn clone(&self) -> TtyHandle

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl From<TtyHandle> for Handle

source§

fn from(tty: TtyHandle) -> Handle

Converts to this type from the input type.
source§

impl From<TtyHandle> for StreamHandle

source§

fn from(tty: TtyHandle) -> StreamHandle

Converts to this type from the input type.
source§

impl HandleTrait for TtyHandle

source§

fn is_active(&self) -> bool

Returns non-zero if the handle is active, zero if it’s inactive. What “active” means depends on the type of handle: Read more
source§

fn is_closing(&self) -> bool

Returns non-zero if the handle is closing or closed, zero otherwise. Read more
source§

fn close<CB: Into<CloseCB<'static>>>(&mut self, cb: CB)

Request handle to be closed. close_cb will be called asynchronously after this call. This MUST be called on each handle before memory is released. Moreover, the memory can only be released in close_cb or after it has returned. Read more
source§

fn ref(&mut self)

Reference the given handle. References are idempotent, that is, if a handle is already referenced calling this function again will have no effect.
source§

fn unref(&mut self)

Un-reference the given handle. References are idempotent, that is, if a handle is not referenced calling this function again will have no effect.
source§

fn has_ref(&self) -> bool

Returns true if the handle referenced, zero otherwise.
source§

fn send_buffer_size(&mut self, value: i32) -> Result<i32>

Gets or sets the size of the send buffer that the operating system uses for the socket. Read more
source§

fn recv_buffer_size(&mut self, value: i32) -> Result<i32>

Gets or sets the size of the receive buffer that the operating system uses for the socket. Read more
source§

fn get_fileno(&self) -> Result<OsFile>

Gets the platform dependent file descriptor equivalent. Read more
source§

fn get_loop(&self) -> Loop

Returns the Loop associated with this handle.
source§

fn get_type(&self) -> HandleType

Returns the type of the handle.
source§

impl StreamTrait for TtyHandle

source§

fn shutdown<CB: Into<ShutdownCB<'static>>>( &mut self, cb: CB ) -> Result<ShutdownReq>

Shutdown the outgoing (write) side of a duplex stream. It waits for pending write requests to complete. The handle should refer to a initialized stream. The cb is called after shutdown is complete at which point the returned ShutdownReq is automatically destroy()’d.
source§

fn listen<CB: Into<ConnectionCB<'static>>>( &mut self, backlog: i32, cb: CB ) -> Result<()>

Start listening for incoming connections. backlog indicates the number of connections the kernel might queue, same as listen(2). When a new incoming connection is received the uv_connection_cb callback is called.
source§

fn accept(&mut self, client: &mut StreamHandle) -> Result<()>

This call is used in conjunction with listen() to accept incoming connections. Call this function after receiving the connection callback to accept the connection. Before calling this function the client handle must be initialized. Read more
source§

fn read_start<ACB: Into<AllocCB<'static>>, RCB: Into<ReadCB<'static>>>( &mut self, alloc_cb: ACB, read_cb: RCB ) -> Result<()>

Read data from an incoming stream. The read_cb callback will be made several times until there is no more data to read or read_stop() is called. Read more
source§

fn read_stop(&mut self) -> Result<()>

Stop reading data from the stream. The uv_read_cb callback will no longer be called. Read more
source§

fn write<CB: Into<WriteCB<'static>>>( &mut self, bufs: &[impl BufTrait], cb: CB ) -> Result<WriteReq>

Write data to stream. Buffers are written in order. Read more
source§

fn write2<CB: Into<WriteCB<'static>>>( &mut self, send_handle: &StreamHandle, bufs: &[impl BufTrait], cb: CB ) -> Result<WriteReq>

Extended write function for sending handles over a pipe. The pipe must be initialized with ipc == 1. Read more
source§

fn try_write(&mut self, bufs: &[impl BufTrait]) -> Result<i32>

Same as write(), but won’t queue a write request if it can’t be completed immediately. Read more
source§

fn try_write2( &mut self, send_handle: &StreamHandle, bufs: &[impl BufTrait] ) -> Result<i32>

Same as try_write() and extended write function for sending handles over a pipe like write2. Read more
source§

fn is_readable(&self) -> bool

Returns true if the stream is readable, false otherwise.
source§

fn is_writable(&self) -> bool

Returns true if the stream is writable, false otherwise.
source§

fn set_blocking(&mut self, blocking: bool) -> Result<()>

Enable or disable blocking mode for a stream. Read more
source§

fn get_write_queue_size(&self) -> usize

Returns the size of the write queue.
source§

impl ToHandle for TtyHandle

source§

impl ToStream for TtyHandle

source§

impl TryFrom<Handle> for TtyHandle

§

type Error = ConversionError

The type returned in the event of a conversion error.
source§

fn try_from(handle: Handle) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<StreamHandle> for TtyHandle

§

type Error = ConversionError

The type returned in the event of a conversion error.
source§

fn try_from(stream: StreamHandle) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for TtyHandle

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.