docs

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

bare::ffi::wit

On this page

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. The async ABI is std::wit (bare does not depend on core). Blocks come from the C allocator, including the ones the host fills through cabi_realloc; a lifted string or list frees its block once copied into GC memory.

Structs

BlocksSource

pub struct Blocks

The blocks values were lowered into: freed together after an import call; an export's are freed by its post-return function instead.

  • pub const fn new() -> Blocks§

    Source

    No blocks yet.

  • pub fn alloc(self, size: i32, align: i32) -> i32§

    Source

    size bytes aligned to align; an empty block is the address align (the canonical ABI checks only its alignment).

  • pub fn str(self, s: str) -> (i32, i32)§

    Source

    s copied into a block: (address, length).

  • pub fn bytes(self, l: List<u8>) -> (i32, i32)§

    Source

    l copied into a block: (address, length).

  • pub fn free(self)§

    Source

    Free every block and empty the list.

Trait implementations 1

HandleSource

pub struct Handle

The handle of an imported resource, shared by every copy of its value: passing an own on or dropping it empties them all.

  • pub const fn own(h: i32) -> Handle§

    Source

    An owned handle h: it can be passed on as own.

  • pub const fn borrowed(h: i32) -> Handle§

    Source

    A borrowed handle h: it cannot be passed on as own.

  • pub const fn get(self) -> i32§

    Source

    The handle; panics once it was dropped or passed on.

  • pub const fn take(self) -> i32§

    Source

    The handle, given away (an own parameter).

  • pub const fn release(self) -> i32 | none§

    Source

    The handle to drop, if this value still owns one.

Trait implementations 1

TableSource

pub struct Table<T>

The values of an exported resource, by representation (rep): a handle the host holds keeps its value alive here until the host drops it ([dtor]).

  • pub unsafe fn new() -> Table<T>§

    Source

    The caller guarantees one thread at a time uses the table (the bindings make one per component instance).

  • pub fn insert(self, v: T) -> i32§

    Source

    Store v and return its rep, reusing a freed slot first.

  • pub fn get(self, rep: i32) -> T§

    Source

    The value of rep. Panics if it was taken already.

  • pub fn take(self, rep: i32) -> T?§

    Source

    The value of rep, its slot freed; none if it was taken already (a [dtor] after the value came back through an owned handle).

Trait implementations 2
  • impl<T> Debug for Table<T>
  • unsafe impl<T> Sync for Table<T>

ErrorContextSource

pub struct ErrorContext

The component model's error-context: a message for debugging, passed between components.

  • pub fn new(msg: str) -> ErrorContext§

    Source

    A new error context with the debug message msg.

  • pub fn debug_message(self) -> str§

    Source

    Its debug message (the host may give an empty one).

  • pub fn raw(self) -> i32§

    Source

    Its handle, for the generated bindings.

  • pub fn from_raw(h: i32) -> ErrorContext§

    Source

    The error context of handle h, for the generated bindings.

Trait implementations 2
  • impl Debug for ErrorContext
  • impl Drop for ErrorContext

Functions

load_u8Source

pub unsafe fn load_u8(a: i32) -> u8

The u8 at canonical ABI address a. UB unless a is in linear memory.

load_u16Source

pub unsafe fn load_u16(a: i32) -> u16

The u16 at canonical ABI address a. UB unless a is in linear memory and aligned.

load_i32Source

pub unsafe fn load_i32(a: i32) -> i32

The i32 at canonical ABI address a. UB unless a is in linear memory and aligned.

load_i64Source

pub unsafe fn load_i64(a: i32) -> i64

The i64 at canonical ABI address a. UB unless a is in linear memory and aligned.

load_f32Source

pub unsafe fn load_f32(a: i32) -> f32

The f32 at canonical ABI address a. UB unless a is in linear memory and aligned.

load_f64Source

pub unsafe fn load_f64(a: i32) -> f64

The f64 at canonical ABI address a. UB unless a is in linear memory and aligned.

store_u8Source

pub unsafe fn store_u8(a: i32, v: u8)

Store v at canonical ABI address a. UB unless a is writable linear memory.

store_u16Source

pub unsafe fn store_u16(a: i32, v: u16)

Store v at canonical ABI address a. UB unless a is writable, aligned linear memory.

store_i32Source

pub unsafe fn store_i32(a: i32, v: i32)

Store v at canonical ABI address a. UB unless a is writable, aligned linear memory.

store_i64Source

pub unsafe fn store_i64(a: i32, v: i64)

Store v at canonical ABI address a. UB unless a is writable, aligned linear memory.

store_f32Source

pub unsafe fn store_f32(a: i32, v: f32)

Store v at canonical ABI address a. UB unless a is writable, aligned linear memory.

store_f64Source

pub unsafe fn store_f64(a: i32, v: f64)

Store v at canonical ABI address a. UB unless a is writable, aligned linear memory.

f32_bitsSource

pub fn f32_bits(x: f32) -> i32

The bits of x as an i32 flat slot (canonical ABI join).

f32_fromSource

pub fn f32_from(x: i32) -> f32

The f32 whose bits are the flat slot x.

f64_bitsSource

pub fn f64_bits(x: f64) -> i64

The bits of x as an i64 flat slot (canonical ABI join).

f64_fromSource

pub fn f64_from(x: i64) -> f64

The f64 whose bits are the flat slot x.

char_fromSource

pub const fn char_from(x: i32) -> char

The char of the flat slot x; panics when x is not a Unicode scalar value.

bad_caseSource

pub const fn bad_case() -> !

A discriminant out of range.

freeSource

pub unsafe fn free(a: i32)

A block freed by free.

str_takeSource

pub unsafe fn str_take(p: i32, n: i32) -> str

The n UTF-8 bytes at p as a str; frees the block. Panics when the bytes are not UTF-8 (the block is not freed).

bytes_takeSource

pub unsafe fn bytes_take(p: i32, n: i32) -> List<u8>

The n bytes at p; frees the block.

Constants

BLOCKEDSource

pub const BLOCKED: i32 = -1

A copy or call that did not finish at once.

DROPPEDSource

pub const DROPPED: i32 = 1

A copy's result: the other end was dropped.