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

IoFailure

Portable byte-stream failure reason, independent of host errno. Transferred-prefix counts live in IoError.Failure, not this reason. Storage preserves its portable allocator identity. Cancellation/timeout does not silently roll back an already transferred prefix.

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.

IoFailure

pub enum IoFailure

Portable byte-stream failure reason, independent of host errno. Transferred-prefix counts live in IoError.Failure, not this reason. Storage preserves its portable allocator identity. Cancellation/timeout does not silently roll back an already transferred prefix.

IoFailure.LinkResolutionFailure

LinkResolutionFailure;

Reports a native link loop or NoFollow final-link rejection.

IoFailure.OutputFailed

OutputFailed;

Standard output could not accept bytes.

IoFailure.AccessDenied

AccessDenied;

Access was denied.

IoFailure.NotFound

NotFound;

Requested resource does not exist.

IoFailure.AlreadyExists

AlreadyExists;

Exclusive creation found an existing resource.

IoFailure.InvalidInput

InvalidInput;

Input is invalid for the operation.

IoFailure.Closed

Closed;

Owner/provider is closed.

IoFailure.Cancelled

Cancelled;

Cancellation stopped further transfer.

IoFailure.BrokenPipe

BrokenPipe;

Peer cannot receive further bytes.

IoFailure.WouldBlock

WouldBlock;

Immediate operation cannot currently progress.

IoFailure.TimedOut

TimedOut;

Deadline stopped further transfer.

IoFailure.Interrupted

Interrupted;

Provider interruption stopped further transfer.

IoFailure.UnsupportedOperation

UnsupportedOperation;

Provider/resource lacks this operation, independently of access rights. Generic transfer helpers preserve the reason and do not fabricate progress. No filesystem or seek support is implied by implementing a stream concept.

Example

module example.unsupported_stream;
from std.io import IoError, ReadExactly;
from std.prelude import Result;
struct UnsupportedReader {
    pub fn Read(Output: mut byte[]) -> Result<usize, IoError> {
        return .Err { Error = .Failure { Reason = .UnsupportedOperation, Transferred = 0 } };
    }
}
fn Main() -> i32 {
    var Source = default(UnsupportedReader);
    var Output: byte[2] = [0xA1_byte, 0xB2_byte];
    switch ReadExactly(Source, Output) {
        case .Err { Error = Failure } => {
            // Inspect each enum layer with one direct payload pattern.
            switch Failure {
                case .Failure { Reason = Reason, Transferred = Count } if (Reason is .UnsupportedOperation) => { if Count != 0 { return 1; } }
                default => return 2;
            }
        }
        default => return 2;
    }
    if Output[0] != 0xA1_byte || Output[1] != 0xB2_byte { return 3; }
    return 0;
}

IoFailure.ResourceChanged

ResourceChanged;

Repeated concurrent resource changes prevented a bounded snapshot copy.

IoFailure.ResourceUnavailable

ResourceUnavailable;

Provider cannot reserve required resources.

IoFailure.NativeFailure

NativeFailure;

Other portable provider failure.

IoFailure.UnexpectedEof

UnexpectedEof;

Full read reached EOF before requested length.

IoFailure.WriteZero

WriteZero;

Nonempty write reported no progress.

IoFailure.InvalidTransferCount

InvalidTransferCount;

Source reported a count outside the supplied slice.

IoFailure.UnsupportedPathEncoding

UnsupportedPathEncoding;

Selected adapter cannot consume this native path encoding.

IoFailure.InvalidUtf8

InvalidUtf8;

Collected text is not strict UTF-8.

IoFailure.TaskDispatch

TaskDispatch;

Bounded worker admission failed before native I/O.

IoFailure.TaskDispatch.Reason

Reason: TaskDispatchError;

IoFailure.Storage

Storage;

Owned buffer/resource allocation failed.

IoFailure.Storage.Reason

Reason: AllocationError;

IoFailure.Network

Network;

Preserves typed network identity inside structural byte-stream errors. Transfer progress remains on IoError.Failure, not this reason.

IoFailure.Network.Reason

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