Struct glommio::net::UnixStream[][src]

pub struct UnixStream { /* fields omitted */ }
Expand description

A Unix Stream of bytes. This can be used with AsyncRead, AsyncBufRead and AsyncWrite

Implementations

Creates an unnamed pair of connected Unix stream sockets.

Examples

use futures_lite::io::{AsyncReadExt, AsyncWriteExt};
use glommio::{net::UnixStream, LocalExecutor};

let ex = LocalExecutor::default();
ex.run(async move {
    let (mut p1, mut p2) = UnixStream::pair().unwrap();
    let sz = p1.write(&[65u8; 1]).await.unwrap();
    let mut buf = [0u8; 1];
    let sz = p2.read(&mut buf).await.unwrap();
})

Creates a Unix connection to the specified endpoint.

Examples

use glommio::{net::UnixStream, LocalExecutor};

let ex = LocalExecutor::default();
ex.run(async move {
    UnixStream::connect("/tmp/named").await.unwrap();
})

Shuts down the read, write, or both halves of this connection.

Sets the buffer size used on the receive path

gets the buffer size used

Receives data on the socket from the remote address to which it is connected, without removing that data from the queue.

On success, returns the number of bytes peeked. Successive calls return the same data. This is accomplished by passing MSG_PEEK as a flag to the underlying recv system call.

Returns the socket address of the remote peer of this Unix connection.

Examples

use glommio::{net::UnixStream, LocalExecutor};

let ex = LocalExecutor::default();
ex.run(async move {
    let stream = UnixStream::connect("/tmp/named").await.unwrap();
    println!("My peer: {:?}", stream.peer_addr());
})

Returns the socket address of the local half of this Unix connection.

Examples

use glommio::{net::UnixStream, LocalExecutor};

let ex = LocalExecutor::default();
ex.run(async move {
    let stream = UnixStream::connect("/tmp/named").await.unwrap();
    println!("My peer: {:?}", stream.local_addr());
})

Trait Implementations

Attempt to return the contents of the internal buffer, filling it with more data from the inner reader if it is empty. Read more

Tells this buffer that amt bytes have been consumed from the buffer, so they should no longer be returned in calls to poll_read. Read more

Attempt to read from the AsyncRead into buf. Read more

Attempt to read from the AsyncRead into bufs using vectored IO operations. Read more

Attempt to write bytes from buf into the object. Read more

Attempt to flush the object, ensuring that any buffered data reach their destination. Read more

Attempt to close the object. Read more

Attempt to write bytes from bufs into the object using vectored IO operations. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Returns the contents of the internal buffer, filling it with more data if empty. Read more

Consumes amt buffered bytes. Read more

Reads all bytes and appends them into buf until the delimiter byte or EOF is found. Read more

Reads all bytes and appends them into buf until a newline (the 0xA byte) or EOF is found. Read more

Returns a stream over the lines of this byte stream. Read more

Returns a stream over the contents of this reader split on the specified byte. Read more

Reads some bytes from the byte stream. Read more

Like read(), except it reads into a slice of buffers. Read more

Reads the entire contents and appends them to a Vec. Read more

Reads the entire contents and appends them to a String. Read more

Reads the exact number of bytes required to fill buf. Read more

Creates an adapter which will read at most limit bytes from it. Read more

Converts this [AsyncRead] into a [Stream] of bytes. Read more

Creates an adapter which will chain this stream with another. Read more

Boxes the reader and changes its type to dyn AsyncRead + Send + 'a. Read more

Writes some bytes into the byte stream. Read more

Like write(), except that it writes a slice of buffers. Read more

Writes an entire buffer into the byte stream. Read more

Flushes the stream to ensure that all buffered contents reach their destination. Read more

Closes the writer. Read more

Boxes the writer and changes its type to dyn AsyncWrite + Send + 'a. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more