Coverage Report

Created: 2026-03-18 17:32

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::opcode as opcodes;
14
pub use core::reader::types::{
15
    global::GlobalType, ExternType, FuncType, Limits, MemType, NumType, RefType, ResultType,
16
    TableType, ValType,
17
};
18
pub use core::rw_spinlock;
19
pub use execution::error::{RuntimeError, TrapError};
20
21
pub use execution::store::*;
22
pub use execution::value::Value;
23
pub use execution::*;
24
pub use validation::*;
25
26
pub(crate) mod core;
27
pub(crate) mod execution;
28
pub(crate) mod validation;
29
30
/// A definition for a [`Result`] using the optional [`Error`] type.
31
pub type Result<T> = ::core::result::Result<T, Error>;
32
33
/// An opt-in error type useful for merging all error types of this crate into a single type.
34
///
35
/// Note: This crate does not use this type in any public interfaces, making it optional for downstream users.
36
#[derive(Debug, PartialEq, Eq)]
37
pub enum Error {
38
    Validation(ValidationError),
39
    RuntimeError(RuntimeError),
40
}
41
42
impl From<ValidationError> for Error {
43
1
    fn from(value: ValidationError) -> Self {
44
1
        Self::Validation(value)
45
1
    }
46
}
47
48
impl From<RuntimeError> for Error {
49
1
    fn from(value: RuntimeError) -> Self {
50
1
        Self::RuntimeError(value)
51
1
    }
52
}
53
54
#[cfg(test)]
55
mod test {
56
    use crate::{Error, RuntimeError, ValidationError};
57
58
    #[test]
59
1
    fn error_conversion_validation_error() {
60
1
        let validation_error = ValidationError::InvalidMagic;
61
1
        let error: Error = validation_error.into();
62
63
1
        assert_eq!(error, Error::Validation(ValidationError::InvalidMagic))
64
1
    }
65
66
    #[test]
67
1
    fn error_conversion_runtime_error() {
68
1
        let runtime_error = RuntimeError::ModuleNotFound;
69
1
        let error: Error = runtime_error.into();
70
71
1
        assert_eq!(error, Error::RuntimeError(RuntimeError::ModuleNotFound))
72
1
    }
73
}