Skip to main content

linera_witty/
lib.rs

1// Copyright (c) Zefchain Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Linera Witty
5//!
6//! This crate allows generating [WIT] files and host side code to interface with WebAssembly guests
7//! that adhere to the [WIT] interface format. The source of truth for the generated code and WIT
8//! files is the Rust source code.
9//!
10//! [WIT]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md
11
12#![deny(missing_docs)]
13// This crate's purpose is generating FFI integer plumbing between WIT and
14// Rust — width-changing and sign-changing casts are part of the job at the
15// boundary.
16#![allow(
17    clippy::cast_possible_truncation,
18    clippy::cast_sign_loss,
19    clippy::cast_possible_wrap
20)]
21
22#[macro_use]
23mod macro_utils;
24
25mod exported_function_interface;
26mod imported_function_interface;
27mod memory_layout;
28mod primitive_types;
29mod runtime;
30#[cfg(with_testing)]
31pub mod test;
32mod type_traits;
33mod util;
34pub mod wit_generation;
35
36pub use frunk::{hlist, hlist::HList, hlist_pat, HCons, HList, HNil};
37#[cfg(with_wit_export)]
38pub use linera_witty_macros::wit_export;
39#[cfg(with_macros)]
40pub use linera_witty_macros::{wit_import, WitLoad, WitStore, WitType};
41
42#[cfg(with_wasmer)]
43pub use self::runtime::wasmer;
44#[cfg(with_wasmtime)]
45pub use self::runtime::wasmtime;
46#[cfg(with_testing)]
47pub use self::runtime::{MockExportedFunction, MockInstance, MockResults, MockRuntime};
48pub use self::{
49    exported_function_interface::{ExportFunction, ExportTo, ExportedFunctionInterface},
50    imported_function_interface::ImportedFunctionInterface,
51    memory_layout::{JoinFlatLayouts, Layout},
52    runtime::{
53        GuestPointer, Instance, InstanceWithFunction, InstanceWithMemory, Memory, Runtime,
54        RuntimeError, RuntimeMemory,
55    },
56    type_traits::{RegisterWitTypes, WitLoad, WitStore, WitType},
57    util::{Merge, Split},
58};