Expand description
IO: Handle (async operations on std’s sockets and files), the
futures-io traits, and the utilities every stream gets: the reads and
writes of AsyncReadExt, AsyncWriteExt, AsyncBufReadExt and
AsyncSeekExt as futures, ReadBuf, copy and
copy_bidirectional, BufReader, BufWriter and BufStream,
the in-memory pipes duplex and simplex, split, empty,
repeat and sink, the process’s stdin, stdout and
stderr, what the sockets’ readiness calls take and answer
(Interest, Ready), the caller’s own buffers the owned calls take
and give back (IoBuf, IoBufMut, IoVecBuf, IoVecBufMut,
AlignedBuf), and on unix AsyncFd, a caller’s own
descriptor driven by readiness.
Inside, the shards’ half of IO: sources, the drivers’ half of every handle, and the system calls they make. A handle’s IO object stays its own (std’s sockets and files); its source is what the shard’s driver reaches. The driver completes every operation, into and out of the pool’s buffers, at once when it can and on readiness otherwise, and wakes the task, which takes the result.
Modules§
Structs§
- Aligned
Buf - A buffer of a fixed capacity whose memory starts at an address that is
a multiple of a chosen alignment: the buffer a file opened for direct IO
(
O_DIRECT,FILE_FLAG_NO_BUFFERING) is read into and written from by the owned calls (Handle::read_at_owned,Handle::write_at_ownedand the others), which hand its memory to the kernel as it is. - BufReader
- A reader with a buffer in front: small reads take from the buffer, which is filled by large reads of the reader. Writes, if the reader is also a writer, go straight through.
- BufStream
- A stream with a read buffer and a write buffer in front: a
BufReaderaround aBufWriter. - BufWriter
- A writer with a buffer in front: small writes gather in the buffer, which goes to the writer when full, on a flush, or on a close. Reads, if the writer is also a reader, go straight through. Dropping it loses what is still buffered: flush or close it first.
- Chain
- A reader that reads one to its end, then another; made by
chain. - Duplex
Stream - One end of a
duplexpair: what it writes the other reads, and what the other writes it reads. Dropping it ends the other’s reads (after what is left) and fails the other’s writes. - Empty
- A reader at its end at once, and a writer that takes every byte and
keeps none. Made by
empty. - FillBuf
- The future of
fill_buf. - Flush
- The future of
flush. - Handle
- An IO object (a socket, a pipe, a file) whose operations run on nuclei’s shards.
- Interest
- What a readiness call waits for: reading, writing, or either.
- Lines
- The lines of a buffered reader; made by
lines. - Read
- The future of
read. - ReadBuf
- A buffer being filled by reads: its first
filledbytes hold data, its firstinitializedbytes are initialized (filled <= initialized), and the rest may be uninitialized memory that a read may write into. - Read
BufFuture - The future of
read_buf. - Read
Exact - The future of
read_exact. - Read
Half - The read half of a stream
splitin two. - Read
Line - The future of
read_line. - Read
Number - The future of a typed read (
read_u32and the like). - Read
ToEnd - The future of
read_to_end. - Read
ToString - The future of
read_to_string. - Read
Until - The future of
read_until. - Ready
- What a readiness call found.
- Repeat
- A reader that gives one byte over and over, without end. Made by
repeat. - Seek
- The future of
seekand the seeks built on it. - Shutdown
- The future of
shutdown. - Simplex
Reader - The reading end of a
simplexpipe. Dropping it fails the writer’s next write. - Simplex
Writer - The writing end of a
simplexpipe. Dropping it (or closing it) ends the reader’s reads after what is left. - Sink
- A writer that takes every byte and keeps none. Made by
sink. - Split
- The segments of a buffered reader between a byte; made by
split. - Stderr
- The process’s standard error: writes run on the blocking pool, one at a time.
- Stdin
- The process’s standard input: reads run on the blocking pool.
- Stdout
- The process’s standard output: writes run on the blocking pool, one at a time; flush before the process exits to see the last one done.
- Take
- A reader that ends after a number of bytes of another; made by
take. - Write
- The future of
write. - Write
All - The future of
write_all. - Write
Half - The write half of a stream
splitin two. - Write
Number - The future of a typed write (
write_u32and the like). - Write
Vectored - The future of
write_vectored.
Traits§
- Async
BufRead - Read bytes asynchronously.
- Async
BufRead Ext - Reads on any
AsyncBufRead: up to a delimiter, a line, the lines or the segments one by one. - Async
Read - Read bytes asynchronously.
- Async
Read Ext - Reads on any
AsyncRead: into a slice, aReadBuf, to the end, as typed numbers in big or little endian. - Async
Seek - Seek bytes asynchronously.
- Async
Seek Ext - Seeks on any
AsyncSeek. - Async
Write - Write bytes asynchronously.
- Async
Write Ext - Writes on any
AsyncWrite: a slice, all of a slice, typed numbers in big or little endian; and its flush and shutdown. - IoBuf
- A buffer an owned write takes: memory at an address that does not move
while the runtime holds the buffer, whose first
bytes_initbytes are written. - IoBuf
Mut - A buffer an owned read fills: an
IoBufwhose memory past the bytes it holds may be written, and told how many hold data after a read. - IoObject
- An IO object a
Handletakes over: on unix anything with a file descriptor; on Windows std’sTcpStream,TcpListener,UdpSocketandFile. - IoVec
Buf - The buffers of an owned vectored write: each one’s bytes, in order, go
out as one write. Implemented for
Vec<B>and[B; N]of anyIoBuf,Vec<Vec<u8>>among them. - IoVec
BufMut - The buffers of an owned vectored read: the bytes read fill each one’s
spare capacity in order. Implemented for
Vec<B>and[B; N]of anyIoBufMut.
Functions§
- copy
- Copies everything
readergives intowriter, then flushes it; answers the bytes copied. - copy_
bidirectional - Copies
aintobandbintoaat once, in the calling task, each direction through a buffer of 8 KiB; a direction whose reader ends closes its writer. Answers the bytes copied each way,(a to b, b to a), once both ended; the first error ends both. - copy_
bidirectional_ with_ sizes copy_bidirectionalwith a buffer ofa_to_bbytes for one direction and ofb_to_abytes for the other.- copy_
buf - Copies everything a buffered
readergives intowriterfrom the reader’s own buffer, then flushes it; answers the bytes copied. - duplex
- Two connected in-memory streams, each direction a pipe of
max_buf_sizebytes: a write waits while its pipe is full. - empty
- A reader at its end at once, and a writer that takes every byte and keeps none.
- repeat
- A reader that gives
byteover and over, without end. - simplex
- One in-memory pipe of
max_buf_sizebytes: what the writer writes, the reader reads. - sink
- A writer that takes every byte and keeps none.
- split
- Splits
streaminto a read half and a write half;ReadHalf::unsplitputs them back together. - stderr
- The process’s standard error, as an async stream (see
Stderr). - stdin
- The process’s standard input, as an async stream (see
Stdin). - stdout
- The process’s standard output, as an async stream (see
Stdout).