Skip to main content

wasmer_artifact/
lib.rs

1//! Generic Artifact abstraction for Wasmer Engines.
2
3#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
4#![warn(unused_import_braces)]
5#![cfg_attr(
6    feature = "cargo-clippy",
7    allow(clippy::new_without_default, clippy::new_without_default)
8)]
9#![cfg_attr(
10    feature = "cargo-clippy",
11    warn(
12        clippy::float_arithmetic,
13        clippy::mut_mut,
14        clippy::nonminimal_bool,
15        clippy::option_map_unwrap_or,
16        clippy::option_map_unwrap_or_else,
17        clippy::print_stdout,
18        clippy::unicode_not_nfc,
19        clippy::use_self
20    )
21)]
22
23mod artifact;
24mod error;
25mod funcbody;
26
27pub use crate::artifact::{ArtifactCreate, MetadataHeader, Upcastable};
28pub use crate::error::{DeserializeError, ImportError, PreInstantiationError, SerializeError};
29pub use crate::funcbody::VMFunctionBody;
30use loupe::MemoryUsage;
31
32/// Version number of this crate.
33pub const VERSION: &str = env!("CARGO_PKG_VERSION");
34
35/// A safe wrapper around `VMFunctionBody`.
36#[derive(Clone, Copy, Debug, MemoryUsage)]
37#[repr(transparent)]
38pub struct FunctionBodyPtr(pub *const VMFunctionBody);
39
40impl std::ops::Deref for FunctionBodyPtr {
41    type Target = *const VMFunctionBody;
42
43    fn deref(&self) -> &Self::Target {
44        &self.0
45    }
46}
47
48/// # Safety
49/// The VMFunctionBody that this points to is opaque, so there's no data to
50/// read or write through this pointer. This is essentially a usize.
51unsafe impl Send for FunctionBodyPtr {}
52/// # Safety
53/// The VMFunctionBody that this points to is opaque, so there's no data to
54/// read or write through this pointer. This is essentially a usize.
55unsafe impl Sync for FunctionBodyPtr {}