1#![warn(missing_docs)]
36#![warn(rust_2018_idioms)]
37
38mod capabilities;
39mod compile;
40mod convert;
41mod engine;
42mod error;
43mod limits;
44mod macros;
45mod pool;
46mod sandbox;
47mod value;
48
49pub use capabilities::{Capabilities, Capability};
50pub use compile::{compile_source, compile_file, validate_bytecode, CompileOptions, CompileResult, Metadata};
51pub use convert::{FromValue, IntoValue, ValueConversionError};
52#[cfg(feature = "serde-support")]
53pub use convert::{from_value_serde, to_value_serde};
54pub use engine::{Engine, EngineConfig, ExecutionContext, HostRegistry, HostFn};
55pub use error::{Error, Result};
56pub use macros::typed_host_fn_2;
57pub use limits::{Limits, LimitViolation};
58pub use pool::{EnginePool, PoolConfig, PoolHandle, PoolStats};
59pub use sandbox::{Sandbox, SandboxConfig, PathPolicy, NetPolicy};
60pub use value::{Value, ValueType};
61
62pub const VERSION: &str = env!("CARGO_PKG_VERSION");
64
65pub const MIN_FUSABI_VERSION: &str = "0.18.0";
67
68pub const MAX_FUSABI_VERSION: &str = "0.19.0";
70
71pub fn is_compatible_version(version: &str) -> bool {
73 let parts: Vec<&str> = version.split('.').collect();
75 if parts.len() < 2 {
76 return false;
77 }
78
79 let Ok(major) = parts[0].parse::<u32>() else {
80 return false;
81 };
82 let Ok(minor) = parts[1].parse::<u32>() else {
83 return false;
84 };
85
86 major == 0 && (minor == 18 || minor == 19)
88}
89
90#[cfg(test)]
91mod tests {
92 use super::*;
93
94 #[test]
95 fn test_version_compatibility() {
96 assert!(is_compatible_version("0.18.0"));
97 assert!(is_compatible_version("0.18.5"));
98 assert!(is_compatible_version("0.19.0"));
99 assert!(!is_compatible_version("0.17.0"));
100 assert!(!is_compatible_version("0.20.0"));
101 assert!(!is_compatible_version("1.0.0"));
102 assert!(!is_compatible_version("invalid"));
103 }
104}