wasmi_c_api/types/mod.rs
1mod export;
2mod r#extern;
3mod func;
4mod global;
5mod import;
6mod memory;
7mod table;
8mod val;
9
10pub use self::{
11 export::*,
12 func::*,
13 global::*,
14 import::*,
15 memory::*,
16 r#extern::*,
17 table::*,
18 val::*,
19};
20
21/// Utility type representing minimum and maximum limitations for Wasm types.
22///
23/// # Examples
24///
25/// This could represent the minimum and maximum number of pages for a Wasm [`MemoryType`].
26///
27/// [`MemoryType`]: wasmi::MemoryType
28#[repr(C)]
29#[derive(Clone)]
30pub struct wasm_limits_t {
31 /// The minimum limit for the Wasm type.
32 pub min: u32,
33 /// The maximum limit for the Wasm type.
34 pub max: u32,
35}
36
37impl wasm_limits_t {
38 /// Returns the maximum limit if valid or `None`.
39 ///
40 /// A limit equal to `u32::MAX` is invalid.
41 pub(crate) fn max(&self) -> Option<u32> {
42 if self.max == u32::MAX {
43 None
44 } else {
45 Some(self.max)
46 }
47 }
48}