NativeLoadError
Classifies recoverable failures when loading a typed native library.
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 NativeLoadErrorClassifies 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.