bare::ffi::wit
本页内容
API 参考只有英文版,由标准库源代码中的英文文档注释生成。
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 BlocksThe blocks values were lowered into: freed together after an import call; an export's are freed by its post-return function instead.
No blocks yet.
sizebytes aligned toalign; an empty block is the addressalign(the canonical ABI checks only its alignment).scopied into a block:(address, length).lcopied into a block:(address, length).Free every block and empty the list.
Trait implementations 1
impl Debug for Blocks
HandleSource
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.
An owned handle
h: it can be passed on asown.A borrowed handle
h: it cannot be passed on asown.The handle; panics once it was dropped or passed on.
The handle, given away (an
ownparameter).The handle to drop, if this value still owns one.
Trait implementations 1
impl Debug for Handle
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]).
The caller guarantees one thread at a time uses the table (the bindings make one per component instance).
Store
vand return itsrep, reusing a freed slot first.The value of
rep. Panics if it was taken already.The value of
rep, its slot freed;noneif it was taken already (a[dtor]after the value came back through an owned handle).
ErrorContextSource
pub struct ErrorContextThe component model's error-context: a message for debugging,
passed between components.
A new error context with the debug message
msg.Its debug message (the host may give an empty one).
Its handle, for the generated bindings.
The error context of handle
h, for the generated bindings.
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 = -1A copy or call that did not finish at once.
DROPPEDSource
pub const DROPPED: i32 = 1A copy's result: the other end was dropped.