docs

您正在閱讀 v0.1.0 的文件。Nabi 0.1.0 已停止支援。 最新版本:v0.1.3 →

bare::ffi::library

本頁內容

API 參考只有英文版,由標準函式庫原始碼中的英文文件註解產生。

shared libraries loaded at run time: dlopen on Unix, LoadLibraryW on Windows. A Library is never unloaded implicitly; close is the only way, and it is unsafe because every function pointer taken from it dangles afterwards.

Structs

LoadErrorSource

pub struct LoadError
  • pub const fn path(self) -> str§

    Source

    The path given to open.

  • pub const fn message(self) -> str§

    Source

    The system's reason (dlerror, FormatMessageW).

Trait implementations 6
  • impl PartialEq for LoadError
  • impl Eq for LoadError
  • impl Clone for LoadError
  • impl Display for LoadError
  • impl Debug for LoadError
  • impl Error for LoadError

SymbolErrorSource

pub struct SymbolError

A library has no symbol of that name (Library::symbol).

  • pub const fn name(self) -> str§

    Source

    The symbol asked for.

  • pub const fn message(self) -> str§

    Source

    The system's reason (dlerror, FormatMessageW).

Trait implementations 6
  • impl PartialEq for SymbolError
  • impl Eq for SymbolError
  • impl Clone for SymbolError
  • impl Display for SymbolError
  • impl Debug for SymbolError
  • impl Error for SymbolError

LibrarySource

pub struct Library

A loaded shared library, or the program itself (Library::this).

  • pub fn open(path: str) throws (LoadError) -> Library§

    Source

    Load the shared library at path (a bare name searches the system's library path). Throws with the system's reason.

  • pub fn this() -> Library§

    Source

    The program itself: its own symbols and, on Unix, those of every library it was linked with (strlen). On Windows only what the executable exports.

  • pub fn raw_symbol(self, name: str) throws (SymbolError) -> CPtr<c_void>§

    Source

    The address of symbol name, never null.

  • pub unsafe fn symbol<F>(self, name: str) throws (SymbolError) -> F§

    Source

    Symbol name as F, a C function pointer type (extern "C" fn(f64) -> f64).

    Safety: F must be the symbol's real signature.

  • pub unsafe fn close(self) throws (LoadError)§

    Source

    Unload the library; this() stays loaded.

    Safety: no pointer taken from it (symbol, data it returned) may be used afterwards.

Trait implementations 2