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 BlocksThe 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() -> Blockspub fn alloc(self, size: i32, align: i32) -> i32sizebytes aligned toalign; an empty block is the addressalign(the canonical ABI checks only its alignment).pub fn str(self, s: str) -> (i32, i32)scopied into a block:(address, length).pub fn bytes(self, l: List<u8>) -> (i32, i32)lcopied into a block:(address, length).pub fn free(self)
Handle
pub struct HandleThe 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) -> Handlepub const fn borrowed(h: i32) -> Handlepub const fn get(self) -> i32pub const fn take(self) -> i32The handle, given away (an
ownparameter).pub const fn release(self) -> i32 | noneThe 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) -> i32pub fn get(self, rep: i32) -> Tpub fn take(self, rep: i32) -> T?The value of
rep, its slot freed;noneif 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 ErrorContextThe component model's error-context: a message for debugging,
passed between components.
pub fn new(msg: str) -> ErrorContextpub fn debug_message(self) -> strIts debug message (the host may give an empty one).
pub fn raw(self) -> i32Its 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) -> u8load_u16
pub unsafe fn load_u16(a: i32) -> u16load_i32
pub unsafe fn load_i32(a: i32) -> i32load_i64
pub unsafe fn load_i64(a: i32) -> i64load_f32
pub unsafe fn load_f32(a: i32) -> f32load_f64
pub unsafe fn load_f64(a: i32) -> f64store_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) -> i32f32_from
pub fn f32_from(x: i32) -> f32f64_bits
pub fn f64_bits(x: f64) -> i64f64_from
pub fn f64_from(x: i64) -> f64char_from
pub const fn char_from(x: i32) -> charbad_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) -> strThe 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 = -1A copy or call that did not finish at once.
DROPPED
pub const DROPPED: i32 = 1A copy's result: the other end was dropped.