wasmer_types/
lib.rs

1//! This are the common types and utility tools for using WebAssembly
2//! in a Rust environment.
3//!
4//! This crate provides common structures such as `Type` or `Value`, type indexes
5//! and native function wrappers with `Func`.
6
7#![deny(missing_docs, unused_extern_crates)]
8#![warn(unused_import_braces)]
9#![cfg_attr(feature = "std", deny(unstable_features))]
10#![cfg_attr(not(feature = "std"), no_std)]
11#![cfg_attr(feature = "cargo-clippy", allow(clippy::new_without_default))]
12#![cfg_attr(
13    feature = "cargo-clippy",
14    warn(
15        clippy::float_arithmetic,
16        clippy::mut_mut,
17        clippy::nonminimal_bool,
18        clippy::option_map_unwrap_or,
19        clippy::option_map_unwrap_or_else,
20        clippy::print_stdout,
21        clippy::unicode_not_nfc,
22        clippy::use_self
23    )
24)]
25
26#[cfg(all(feature = "std", feature = "core"))]
27compile_error!(
28    "The `std` and `core` features are both enabled, which is an error. Please enable only once."
29);
30
31#[cfg(all(not(feature = "std"), not(feature = "core")))]
32compile_error!("Both the `std` and `core` features are disabled. Please enable one of them.");
33
34#[cfg(feature = "core")]
35extern crate alloc;
36
37/// The `lib` module defines a `std` module that is identical whether
38/// the `core` or the `std` feature is enabled.
39pub mod lib {
40    /// Custom `std` module.
41    #[cfg(feature = "core")]
42    pub mod std {
43        pub use alloc::{borrow, boxed, format, iter, rc, slice, string, vec};
44        pub use core::{any, cell, cmp, convert, fmt, hash, marker, mem, ops, ptr, sync, u32};
45    }
46
47    /// Custom `std` module.
48    #[cfg(feature = "std")]
49    pub mod std {
50        pub use std::{
51            any, borrow, boxed, cell, cmp, convert, fmt, format, hash, iter, marker, mem, ops, ptr,
52            rc, slice, string, sync, u32, vec,
53        };
54    }
55}
56
57mod archives;
58mod extern_ref;
59mod features;
60mod indexes;
61mod initializers;
62mod memory_view;
63mod module;
64mod native;
65mod types;
66mod units;
67mod values;
68
69/// The entity module, with common helpers for Rust structures
70pub mod entity;
71pub use crate::extern_ref::{ExternRef, VMExternRef};
72pub use crate::features::Features;
73pub use crate::indexes::{
74    CustomSectionIndex, DataIndex, ElemIndex, ExportIndex, FunctionIndex, GlobalIndex, ImportIndex,
75    LocalFunctionIndex, LocalGlobalIndex, LocalMemoryIndex, LocalTableIndex, MemoryIndex,
76    SignatureIndex, TableIndex,
77};
78pub use crate::initializers::{
79    DataInitializer, DataInitializerLocation, OwnedDataInitializer, OwnedTableInitializer,
80};
81pub use crate::memory_view::{Atomically, MemoryView};
82pub use crate::module::{ImportCounts, ModuleInfo};
83pub use crate::native::{NativeWasmType, ValueType};
84pub use crate::units::{
85    Bytes, PageCountOutOfRange, Pages, WASM_MAX_PAGES, WASM_MIN_PAGES, WASM_PAGE_SIZE,
86};
87pub use crate::values::{Value, WasmValueType};
88pub use types::{
89    ExportType, ExternType, FastGasCounter, FunctionType, FunctionTypeRef, GlobalInit, GlobalType,
90    Import, InstanceConfig, MemoryType, Mutability, TableType, Type, V128,
91};
92
93pub use archives::ArchivableIndexMap;
94
95/// Version number of this crate.
96pub const VERSION: &str = env!("CARGO_PKG_VERSION");