Table of Contents

Namespace VpnHood.Net.Toolkit.Streams

Classes

AsyncStream

Base Stream for async-only streams. It centralizes the repetitive plumbing: every synchronous I/O member throws NotSupportedException, and the legacy byte[]-based async overloads are routed to the Memory<T>-based core methods. Derived classes only implement the real I/O: ReadAsync(Memory<byte>, CancellationToken), WriteAsync(ReadOnlyMemory<byte>, CancellationToken), CanRead and CanWrite.

AsyncStreamDecorator<T>

Provides a base for a stream that wraps another one: its asynchronous I/O, capabilities, length, position, seeking and timeouts go to the source, and closing it closes the source, once, unless left open. Synchronous I/O is not supported, as on any AsyncStream.

ReadBufferedStream

Provides a stream that buffers small reads of another stream, to read it in fewer, larger reads; writes go to the source as they are.

ReadOnlySubStream

Provides a read-only, seekable window onto part of another stream: positions start at 0 at the window's start, and the window's end is the stream's end. It reads in place, with no copy, as for an uncompressed entry inside an Android package.

StreamDecoratorAsync

Provides an AsyncStreamDecorator<T> over any stream.

StreamExtensions

Provides stream helpers: reading text, and copying a stream into memory.

StreamUtils

Provides the framing of JSON messages on a stream: a 4-byte little-endian length, then that many bytes of UTF-8 JSON. The readers limit the payload; the writers do not.

Interfaces

IDataStream

Represents a stream that can tell whether data is waiting to be read.