Under heavy development. This site describes the intended 1.0 language. Current features and performance vary. Development status
Sn50SnThe SnAPI programming language
0.2.0 Preview 1 · Frozen documentation

AsyncBufferedReader

Owns a fixed-capacity byte cache and its concrete AsyncReader source. Construction allocates; subsequent cache operations do not grow storage. Mutable receiver loans remain live across suspension; external synchronization is required. Movement transfers the source and cache, leaving the old adapter closed. Destruction never performs hidden I/O.

Sn is under heavy development. Reference extracted from this release’s bundled standard library. Public API examples are not an exhaustive compatibility test. Read the matching release guide for tested workflows and limitations. Read the status →

Module std.io

import std.io;

Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.

AsyncBufferedReader

pub final class AsyncBufferedReader<S> where S: AsyncReader, Movable

Owns a fixed-capacity byte cache and its concrete AsyncReader source. Construction allocates; subsequent cache operations do not grow storage. Mutable receiver loans remain live across suspension; external synchronization is required. Movement transfers the source and cache, leaving the old adapter closed. Destruction never performs hidden I/O. S: Movable structural AsyncReader implementation.

AsyncBufferedReader.init

pub init(Source: readonly Self&) = delete;

Rejects implicit source/cache copying. Source: Existing adapter.

AsyncBufferedReader.operator

pub fn operator =(Source: readonly Self&) -> void = delete;

Rejects replacement that could silently discard pending bytes. Source: Existing adapter. Return: No runtime result; this assignment is deleted and cannot be invoked.

AsyncBufferedReader.operator

pub fn operator =(Source: mut Self&&) -> void = delete;

Requires explicit finishing/extraction before replacing an adapter. Source: Existing adapter. Return: No runtime result; this assignment is deleted and cannot be invoked.

AsyncBufferedReader.Capacity

pub Capacity: usize;

Observes initialized cache capacity in bytes.

AsyncBufferedReader.IsClosed

pub IsClosed: bool;

Observes extraction/movement closure without I/O.

AsyncBufferedReader.TryCreate

pub static fn TryCreate(mut Source: S, Capacity: usize) -> Result<Self, BufferedStreamCreationError<S>>

Allocates initialized cache slots and transfers a concrete source. Source: Owned source; returned in the error on failure. Capacity: Positive cache capacity in bytes; default is 8192. Return: Adapter or error retaining the source; no stream I/O occurs. Warning: May allocate.

AsyncBufferedReader.TryCreate

pub static fn TryCreate(mut Source: S) -> Result<Self, BufferedStreamCreationError<S>>

Supplies the omitted arguments to TryCreate. Note: Defaults: Capacity = DefaultBufferCapacity. Source: Same input, ownership and lifetime contract as the full operation. Return: The full synchronous operation's owned success value or typed failure.

AsyncBufferedReader.init

pub init(Source: mut Self&&)

Transfers cache and read-ahead state without I/O. Source: Adapter left closed.

AsyncBufferedReader.BufferedLength

pub BufferedLength: usize;

Counts unread cached bytes.

AsyncBufferedReader.ReadAsync

pub async fn ReadAsync(Output: mut byte[], mut Token: CancellationToken) -> Task<Result<usize, IoError>>

Reads cached bytes or performs one bounded source refill. Output: Borrowed destination retained through task completion. Token: Cancellation observation checked before cached-byte delivery. Return: Task yielding delivered count, EOF zero, or failure with delivered prefix count. Warning: May suspend in the source; do not move/dispose borrowed backing while pending. Failed refills retain any extra valid bytes.

AsyncBufferedReader.ReadAsync

pub fn ReadAsync(Output: mut byte[]) -> Task<Result<usize, IoError>>

Supplies the omitted arguments to ReadAsync. Note: Defaults: Token = CancellationToken(). Output: Same input, ownership and lifetime contract as the full operation. Return: Exact full-operation result; no additional async frame is created.

AsyncBufferedReader.DiscardBufferedBytesAndTakeSource

pub fn DiscardBufferedBytesAndTakeSource() -> S

Transfers the source while deliberately discarding unread cache. Return: Source positioned after any earlier read-ahead, not after consumed bytes. Pre: Adapter has not been moved/extracted. Warning: Invalidates cache; does not rewind.

Documentation snapshot: October 24, 2026 About versions ↗
Searching Development · language & standard library