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

BufferedReader

Owns a fixed-capacity byte cache and its concrete Reader source. Construction allocates; subsequent cache operations do not grow storage. 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.

BufferedReader

pub final class BufferedReader<S> where S: Reader, Movable

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

BufferedReader.init

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

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

BufferedReader.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.

BufferedReader.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.

BufferedReader.Capacity

pub Capacity: usize;

Observes initialized cache capacity in bytes.

BufferedReader.IsClosed

pub IsClosed: bool;

Observes extraction/movement closure without I/O.

BufferedReader.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.

BufferedReader.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.

BufferedReader.init

pub init(Source: mut Self&&)

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

BufferedReader.BufferedLength

pub BufferedLength: usize;

Counts unread cached bytes.

BufferedReader.Read

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

Reads cached bytes or performs one bounded source refill. Output: Borrowed destination valid for this call. Return: Delivered count, EOF zero, or failure with delivered prefix count. Warning: May block in the source. Failed refills retain any extra valid bytes.

BufferedReader.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