Under heavy development. This site describes the intended 1.0 language. Current features and performance vary. Development status
Sn50SnThe SnAPI programming language
Snapshot · Oct 24, 2026 · Frozen documentation

NativeLoadError

Classifies recoverable failures when loading a typed native library.

Sn is under heavy development. This reference includes the intended 1.0 design; features may be incomplete in the current compiler. Read the status →

Module std.abi

import std.abi;

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

NativeLoadError

pub enum NativeLoadError

Classifies recoverable failures when loading a typed native library.

Errors own their payload without allocation or borrowed platform error text. RequiredSymbolUnavailable identifies the declaration-order stored-field ordinal in the requested table, starting at zero. Unsupported targets, ABI profiles and table types are compile-time errors rather than load failures.

Example

module example.native_load_error;
from std.abi import NativeLoadError;

fn FailureCode(Failure: NativeLoadError) -> usize {
    switch Failure {
        case .InvalidPath => return 1;
        case .OpenFailed => return 2;
        case .RequiredSymbolUnavailable { Field = Ordinal } => return 3 + Ordinal;
        case .OutOfMemory => return 4;
    }
}

fn Main() -> i32 {
    let Missing: NativeLoadError = .RequiredSymbolUnavailable { Field = 2 };
    if FailureCode(.InvalidPath) != 1 || FailureCode(.OpenFailed) != 2 ||
        FailureCode(Missing) != 5 || FailureCode(.OutOfMemory) != 4 {
        return 1;
    }
    return 0;
}
Documentation snapshot: October 24, 2026 About versions ↗
Searching Development · language & standard library