docs

You are reading the docs for v0.1.2. Nabi 0.1.2 is no longer supported. Latest release: v0.1.3 →

Standard library API

API listing generated from the public items and doc comments of the standard library sources (library/). Behavior and guarantees are defined in the standard library specification.

bare

The lowest layer: pointers, memory, FFI.

  • bare raw pointers, transmute, raw allocation, pinning and volatile access, over the runtime's extern "nabi" symbols only.
  • bare::alloc raw allocation outside the GC.
  • bare::ffi C's types (types, also in the prelude), errno (errno), Nabi values C holds (handle), NUL-terminated C strings (wide: wchar_t ones), loading shared libraries (library); wit is what the WIT bindings run on; objc, Objective-C objects, exists only on Apple targets.
  • bare::ffi::errno the C library's errno and Windows' GetLastError as the last #[errno] call left them.
  • bare::ffi::handle Nabi values C code holds as a void*.
  • bare::ffi::library shared libraries loaded at run time: dlopen on Unix, LoadLibraryW on Windows.
  • bare::ffi::objc Objective-C objects on Apple targets.
  • bare::ffi::objc::block Nabi closures as Objective-C blocks, laid out as the Apple block ABI says.
  • bare::ffi::objc::dispatch Grand Central Dispatch: run a closure on the main queue or a global one, through a Block.
  • bare::ffi::objc::error NSError, what a method that reports through a last NSError ** parameter throws.
  • bare::ffi::objc::string NSString and str.
  • bare::ffi::objc::subclass classes made at run time (objc_allocateClassPair): Nabi functions as an Objective-C class's methods, for delegates and the classes an API wants subclassed.
  • bare::ffi::types C's integer and float types under their C names, as the target's C compiler sizes them.
  • bare::ffi::wide NUL-terminated wchar_t strings: UTF-16 on Windows (the W APIs), one unit per char (UTF-32) elsewhere.
  • bare::ffi::wit what the generated WIT bindings run on: linear-memory access at canonical ABI addresses (i32), the blocks strings and lists lower into, resource handles and error-context.
  • bare::gc the collector's controls, and keeping GC objects in place for raw pointers.
  • bare::mem raw memory operations, Pod and bit casts.
  • bare::ptr raw pointers.
  • bare::volatile accesses the optimizer keeps exactly as written: MMIO, signal flags, DMA buffers.

core

Collections, numbers, iterators, formatting, synchronization, tasks. Available to all code automatically.

  • core core tier (foundation) - safe, target-independent.
  • core::array Clone / Copy / Default / Debug / PartialEq / Eq / Hash for fixed arrays [T; N], element-wise, and PartialOrd / Ord, lexicographic; and Array<T, N>, the n-dimensional array.
  • core::bench the engine nabi bench drives.
  • core::channel message passing between threads.
  • core::cmp total equality, ordering and hashing.
  • core::collections List / Dict / Set / Slice, Deque, BinaryHeap, SortedDict / SortedSet, and the frozen (read-only, Sync) List / Dict / Set.
  • core::collections::broadcast the element-wise dot operators on List<T>: List op List (same length, else a panic), List op T and T op List (the scalar applies to every element).
  • core::collections::deque Deque<T>, a growable ring buffer with O(1) push and pop at both ends.
  • core::collections::dict Dict<K, V, S>, a hash map hashing with S (the process-keyed RandomState by default), compact: entries are appended to dense key / value / hash arrays, and a power-of-two index of linear-probed slots maps a hash to its entry.
  • core::collections::frozen FrozenList, FrozenDict and FrozenSet: a collection that no one can change any more, shared between threads without a lock and without a copy.
  • core::collections::heap BinaryHeap<T>, a priority queue over a List laid out as an implicit binary tree.
  • core::collections::list List<T>, a growable array: one object holding the length, the capacity and the current element buffer, swapped for a bigger one on growth.
  • core::collections::set Set<T, S>, a hash set over Dict<T, bool, S>, so it iterates in insertion order.
  • core::collections::slice Slice<T>, a zero-copy view; element i is buf[start + i * stride], and the view keeps its buffer alive.
  • core::collections::sorted SortedDict<K, V> and SortedSet<T>: ordered by K: Ord, kept in a B-tree.
  • core::convert conversion traits and primitive impls.
  • core::crypto Cryptographic algorithms: pure computation, no OS (randomness is std::random).
  • core::crypto::aead Authenticated encryption with associated data: AES-GCM (NIST SP 800-38D, 96-bit nonces) and ChaCha20-Poly1305 (RFC 8439).
  • core::crypto::ecdsa ECDSA (FIPS 186-5) on P-256 and P-384: verification, and signing with RFC 6979 deterministic nonces.
  • core::crypto::ed25519 Ed25519 (RFC 8032 5.1): pure EdDSA over edwards25519 with SHA-512.
  • core::crypto::hkdf HKDF (RFC 5869) over any HashAlgorithm: extract a pseudorandom key, expand it into output keying material.
  • core::crypto::hmac HMAC (RFC 2104) over any HashAlgorithm, SHA-2 or SHA-3.
  • core::crypto::mlkem ML-KEM-768 (FIPS 203): k = 3, eta1 = eta2 = 2, du = 10, dv = 4.
  • core::crypto::rsa RSA (RFC 8017): PKCS #1 v1.5 and PSS verification and signing (MGF1 with the message hash), moduli of 2048 to 4096 bits.
  • core::crypto::secret Secret storage: a buffer in the large-object space, so the collector never moves or copies it, zeroed by wipe, by using release and by the collection that frees it (nabi_gc_secret_new).
  • core::crypto::sha2 SHA-2 (FIPS 180-4): SHA-256, SHA-384 and SHA-512.
  • core::crypto::sha3 SHA-3 (FIPS 202): SHA3-256, SHA3-512 and the SHAKE128 / SHAKE256 extendable-output functions, all over Keccak-f[1600].
  • core::crypto::x25519 X25519 (RFC 7748): Diffie-Hellman on Curve25519's u coordinate.
  • core::encoding bytes as text (RFC 4648): hex and base64.
  • core::encoding::base64 base64 (RFC 4648 sections 4 and 5).
  • core::encoding::hex base16 (RFC 4648 section 8): two digits per byte.
  • core::error Result<T, E>, an error kept as a value.
  • core::fmt Formatter, Display / Debug, FormatSpec and the f-string lowering targets.
  • core::future Future / Poll / Context / Waker / IntoFuture.
  • core::hash what a Hash impl writes to: Hasher, BuildHasher, the process-keyed RandomState that Dict and Set default to with its SipHash-1-3 DefaultHasher, and the caller-keyed SipHasher13 / SipHasher24, whose output is stable.
  • core::hint hints the optimizer honors.
  • core::index Indexing + slicing traits.
  • core::io IoError, the byte-stream traits Read, BufRead, Write, Seek and their async twins, the buffers, Cursor, copy and the standard streams.
  • core::iter Iterator + IntoIterator + FromIterator.
  • core::marker Marker traits used by #[derive(..)] and other compiler-driven semantics.
  • core::num the primitive types' operator / comparison trait impls.
  • core::num::bigfloat float.
  • core::num::bigint int, the arbitrary-precision integer.
  • core::num::half f16 (IEEE 754 binary16) and bf16 (bfloat16), storage types held as their 16 bits.
  • core::num::niche wrappers that leave out values: NonZero<T> (0), NonNan<F> (NaN), Finite<F> (NaN, +/-inf), Positive<T> (negatives).
  • core::ops Operator traits: the source of every operator token.
  • core::panic the compiler hooks panic_fn / oom_fn / unreachable_fn: print a message to stderr and exit 101.
  • core::par data-parallel helpers, on the process's task executor (core::task): from async code on the worker it runs on, from sync code with the caller as a guest worker.
  • core::prelude the names every file outside the library sees bare: user code gets an implicit use core::prelude::*; unless the file says #![no_implicit_nabi].
  • core::print print / println / eprint / eprintln, dbg and display (the prelude names them, so they need no use).
  • core::range Range / RangeInclusive / RangeFrom / RangeTo / RangeToInclusive / RangeFull.
  • core::reflect Reflect / Inspect.
  • core::reflect::attr runtime attributes: values of a #[runtime_attribute(name)] struct written as #[name(..)] on a type, field or variant, kept in read-only data.
  • core::reflect::field Field, one field of a struct or variant.
  • core::reflect::info TypeInfo, a type's description.
  • core::simd portable SIMD: Simd<T, N> holds N lanes of a number T, and its operators work on every lane at once.
  • core::str str methods and trait impls.
  • core::str::unicode Unicode text on str: normalization forms, full case folding, and segmentation into grapheme clusters (user-perceived characters) and words.
  • core::stream Stream / IntoStream / FromStream.
  • core::sync concurrency primitives.
  • core::task tasks on the work-stealing executor and block_on; Duration / Instant are core::time.
  • core::time Duration / Instant.
  • core::tuple Clone / Copy / Default / Debug / PartialEq / Eq / Hash for tuples of 1 to 12 elements, component-wise, and PartialOrd / Ord, lexicographic.

std

Files, networking, time, threads, processes, environment, NABION.

  • std the target-dependent tier.
  • std::env arguments, environment variables, directories.
  • std::fs files and directories over the openat family, so a Dir handle is a capability.
  • std::nabion NABION (Nabi Object Notation, .nabion): one value written in Nabi literal syntax.
  • std::net TCP / UDP sockets, addresses, DNS.
  • std::net::tls TLS 1.3, implemented here in Nabi on core::crypto: no OS or external TLS library.
  • std::os what only some OSes have.
  • std::os::linux Linux-only parts of the cross-platform modules.
  • std::os::linux::net Linux-only socket calls.
  • std::os::linux::process Linux-only parts of process.
  • std::os::unix Unix-only parts of the cross-platform modules.
  • std::os::unix::fs the Unix side of the cross-platform fs types: permission bits, the open functions' os records, and openat(2) itself with its O_* flags.
  • std::os::unix::io raw file descriptors.
  • std::os::unix::net Unix domain sockets.
  • std::os::unix::process Unix-only parts of process.
  • std::os::windows Windows-only parts of the cross-platform modules.
  • std::os::windows::fs the Windows side of the cross-platform fs types: the open functions' os records and CreateFile2 itself with its constants.
  • std::os::windows::io raw handles and sockets.
  • std::os::windows::process Windows-only parts of process.
  • std::panic a hook that sees every panic before the process ends (or, under #[on_panic], before the C caller gets its value back).
  • std::path Path, a UTF-8 path value with Python-style / joining.
  • std::plugin load a plugin into this program and call its functions.
  • std::process child processes.
  • std::random cryptographically secure random bytes from the OS (getrandom on Linux, getentropy on macOS, BCryptGenRandom on Windows, random_get on WASI), seedable generators (Rng) with ranges of any integer type and the common distributions, and one-call forms over a shared generator.
  • std::reload hot reload under nabi dev: where changes apply, code that runs around them, and state that lives through them.
  • std::thread OS threads, 1:1.
  • std::time the wall clock (SystemTime), the boot clock (BootTime), and the civil calendar: Date, Time, DateTime, Offset, TimeZone and Zoned, with ISO 8601 / RFC 3339 text and strftime-style format / parse_with.
  • std::wit the component model's async ABI (WASI preview 3) for the bindings ffi::wit::import / ffi::wit::export generate: it runs on the executor, so it lives above bare::ffi::wit.