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

NativeLoadError

Classifies recoverable failures when loading a typed native library.

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

NativeLoadError.InvalidPath

InvalidPath;

Reports an invalid library path.

NativeLoadError.OpenFailed

OpenFailed;

Reports that the platform could not open the requested library.

NativeLoadError.RequiredSymbolUnavailable

RequiredSymbolUnavailable;

Reports that the requested required symbol lookup returned no address.

NativeLoadError.RequiredSymbolUnavailable.Field

Field: usize;

Zero-based declaration-order stored-field ordinal in the table.

NativeLoadError.OutOfMemory

OutOfMemory;

Reports that loading could not acquire required storage.

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