pub trait StreamTrait: ToStream {
Show 13 methods // Provided methods fn shutdown<CB: Into<ShutdownCB<'static>>>( &mut self, cb: CB ) -> Result<ShutdownReq> { ... } fn listen<CB: Into<ConnectionCB<'static>>>( &mut self, backlog: i32, cb: CB ) -> Result<()> { ... } fn accept(&mut self, client: &mut StreamHandle) -> Result<()> { ... } fn read_start<ACB: Into<AllocCB<'static>>, RCB: Into<ReadCB<'static>>>( &mut self, alloc_cb: ACB, read_cb: RCB ) -> Result<()> { ... } fn read_stop(&mut self) -> Result<()> { ... } fn write<CB: Into<WriteCB<'static>>>( &mut self, bufs: &[impl BufTrait], cb: CB ) -> Result<WriteReq> { ... } fn write2<CB: Into<WriteCB<'static>>>( &mut self, send_handle: &StreamHandle, bufs: &[impl BufTrait], cb: CB ) -> Result<WriteReq> { ... } fn try_write(&mut self, bufs: &[impl BufTrait]) -> Result<i32> { ... } fn try_write2( &mut self, send_handle: &StreamHandle, bufs: &[impl BufTrait] ) -> Result<i32> { ... } fn is_readable(&self) -> bool { ... } fn is_writable(&self) -> bool { ... } fn set_blocking(&mut self, blocking: bool) -> Result<()> { ... } fn get_write_queue_size(&self) -> usize { ... }
}

Provided Methods§

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.

When the connection callback is called it is guaranteed that this function will complete successfully the first time. If you attempt to use it more than once, it may fail. It is suggested to only call this function once per connection callback.

Note: server and client must be handles running on the same loop.

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.

Will return EALREADY when called twice, and EINVAL when the stream is closing.

source

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

Stop reading data from the stream. The uv_read_cb callback will no longer be called.

This function is idempotent and may be safely called on a stopped stream.

This function will always succeed; hence, checking its return value is unnecessary. A non-zero return indicates that finishing releasing resources may be pending on the next input event on that TTY on Windows, and does not indicate failure.

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.

Note: The memory pointed to by the buffers must remain valid until the callback gets called.

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.

Note: send_handle must be a TCP, pipe and UDP handle on Unix, or a TCP handle on Windows, which is a server or a connection (listening or connected state). Bound sockets or pipes will be assumed to be servers.

Note: The memory pointed to by the buffers must remain valid until the callback gets called.

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.

Will return number of bytes written (can be less than the supplied buffer size).

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.

Try to send a handle is not supported on Windows, where it returns EAGAIN.

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.

When blocking mode is enabled all writes complete synchronously. The interface remains unchanged otherwise, e.g. completion or failure of the operation will still be reported through a callback which is made asynchronously.

Warning: Relying too much on this API is not recommended. It is likely to change significantly in the future.

Currently only works on Windows for PipeHandles. On UNIX platforms, all Stream handles are supported.

Also libuv currently makes no ordering guarantee when the blocking mode is changed after write requests have already been submitted. Therefore it is recommended to set the blocking mode immediately after opening or creating the stream.

source

fn get_write_queue_size(&self) -> usize

Returns the size of the write queue.

Object Safety§

This trait is not object safe.

Implementors§