Coverage Report

Created: 2026-01-30 16:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/build/source/src/lib.rs
Line
Count
Source
1
#![no_std]
2
#![deny(
3
    clippy::missing_safety_doc,
4
    clippy::undocumented_unsafe_blocks,
5
    unsafe_op_in_unsafe_fn
6
)]
7
8
extern crate alloc;
9
#[macro_use]
10
extern crate log_wrapper;
11
12
pub use core::error::ValidationError;
13
pub use core::reader::types::{
14
    export::ExportDesc, global::GlobalType, Limits, MemType, NumType, RefType, TableType, ValType,
15
};
16
pub use core::rw_spinlock;
17
pub use execution::error::{RuntimeError, TrapError};
18
19
pub use execution::store::*;
20
pub use execution::value::Value;
21
pub use execution::*;
22
pub use validation::*;
23
24
pub(crate) mod core;
25
pub(crate) mod execution;
26
pub(crate) mod validation;
27
28
/// A definition for a [`Result`] using the optional [`Error`] type.
29
pub type Result<T> = ::core::result::Result<T, Error>;
30
31
/// An opt-in error type useful for merging all error types of this crate into a single type.
32
///
33
/// Note: This crate does not use this type in any public interfaces, making it optional for downstream users.
34
#[derive(Debug, PartialEq, Eq)]
35
pub enum Error {
36
    Validation(ValidationError),
37
    RuntimeError(RuntimeError),
38
}
39
40
impl From<ValidationError> for Error {
41
1
    fn from(value: ValidationError) -> Self {
42
1
        Self::Validation(value)
43
1
    }
44
}
45
46
impl From<RuntimeError> for Error {
47
1
    fn from(value: RuntimeError) -> Self {
48
1
        Self::RuntimeError(value)
49
1
    }
50
}
51
52
#[cfg(test)]
53
mod test {
54
    use crate::{Error, RuntimeError, ValidationError};
55
56
    #[test]
57
1
    fn error_conversion_validation_error() {
58
1
        let validation_error = ValidationError::InvalidMagic;
59
1
        let error: Error = validation_error.into();
60
61
1
        assert_eq!(error, Error::Validation(ValidationError::InvalidMagic))
62
1
    }
63
64
    #[test]
65
1
    fn error_conversion_runtime_error() {
66
1
        let runtime_error = RuntimeError::ModuleNotFound;
67
1
        let error: Error = runtime_error.into();
68
69
1
        assert_eq!(error, Error::RuntimeError(RuntimeError::ModuleNotFound))
70
1
    }
71
}