rokdocs
v0.1

rok::bare::ffi::wit

rok::bare::ffi::wit - what the generated WIT bindings run on (stdlib 1.8): linear-memory access at canonical ABI addresses (i32), the blocks strings and lists lower into, resource handles and error-context. The async ABI is rok::std::wit (bare does not depend on core, 0.1.2). 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

Blocks

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
  • pub fn alloc(self, size: i32, align: i32) -> i32

    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)

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

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

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

  • pub fn free(self)

Handle

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
  • pub const fn borrowed(h: i32) -> Handle
  • pub const fn get(self) -> i32
  • pub const fn take(self) -> i32

    The handle, given away (an own parameter).

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

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

Table

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>

    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
  • pub fn get(self, rep: i32) -> T
  • pub fn take(self, rep: i32) -> T?

    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 1
  • unsafe impl<T> Sync for Table<T>

ErrorContext

pub struct ErrorContext

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

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

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

  • pub fn raw(self) -> i32

    Its handle, for the generated bindings.

  • pub fn from_raw(h: i32) -> ErrorContext
Trait implementations 1
  • impl Drop for ErrorContext

Functions

load_u8

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

load_u16

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

load_i32

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

load_i64

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

load_f32

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

load_f64

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

store_u8

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

store_u16

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

store_i32

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

store_i64

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

store_f32

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

store_f64

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

f32_bits

pub fn f32_bits(x: f32) -> i32

f32_from

pub fn f32_from(x: i32) -> f32

f64_bits

pub fn f64_bits(x: f64) -> i64

f64_from

pub fn f64_from(x: i64) -> f64

char_from

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

bad_case

pub const fn bad_case() -> !

A discriminant out of range.

free

pub unsafe fn free(a: i32)

A block freed by free.

str_take

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

The n UTF-8 bytes at p as a str; frees the block.

bytes_take

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

The n bytes at p; frees the block.

Constants

BLOCKED

pub const BLOCKED: i32 = -1

A copy or call that did not finish at once.

DROPPED

pub const DROPPED: i32 = 1

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