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.
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 IoFailurePortable 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;