std/dl
Types
Loader
@unsafeGuarantee(Copy, Send, Sync)
pub type Loader
The dynamic loader; loading a library runs its initialisers, so the capability comes from host.dl() in the entry file like fs and net. Safety: a stateless capability marker; each load it starts is independent, so sharing or duplicating it is free.
Loader.open
pub fn Loader.open(self, path: String) -> Library!
Loads a shared library by file name or path.
Handle
pub type Handle = resource {
// private fields omitted
}
A loaded library handle; closed when the last Library or Symbol sharing it is dropped.
Handle.drop
pub fn Handle.drop(move self)
Closes the library.
Library
pub type Library = resource {
// private fields omitted
}
A shared library loaded with the dynamic loader; unloaded when it and every Symbol taken from it are dropped.
Library.get
pub fn Library.get[T](self, name: String) -> Symbol[T]!
Looks up a function symbol; T is its C function pointer type. A symbol whose value is legitimately NULL is not an error, so success is decided by dlerror (POSIX protocol: clear it, call dlsym, check it again), not by the returned pointer.
Symbol
pub type Symbol[T] = resource {
// private fields omitted
}
A function symbol of a loaded library, typed as T; keeps the library loaded.
Symbol.call
pub unsafe fn Symbol[T].call(self)
Calls the symbol with T's parameters and result; the compiler lowers the call.