#[repr(C)]pub struct ApiVersion {
pub major: u32,
pub minor: u32,
pub patch: u32,
}Expand description
Version of openstranded-common-wasmcontract baked at compile time.
Each WASM plugin exports this via plugin_api_version().
The engine reads it on load to check compatibility.
The version is automatically derived from the Cargo.toml of the
openstranded-common-wasmcontract crate. Plugin authors never set it manually.
§WASM ABI
#[repr(C)] ensures a stable layout when passing across the WASM boundary.
Fields§
§major: u32Major version — breaking changes.
minor: u32Minor version — backwards-compatible additions.
patch: u32Patch version — backwards-compatible bug fixes.
Implementations§
Source§impl ApiVersion
impl ApiVersion
Sourcepub const fn current() -> Self
pub const fn current() -> Self
Current API version, baked from CARGO_PKG_VERSION_* environment variables.
env!() evaluates at compile time, so the version is statically embedded.
§Example
use openstranded_common_wasmcontract::ApiVersion;
let v = ApiVersion::current();
println!("API version: {v}");Sourcepub fn compatible_with(
&self,
engine_version: &ApiVersion,
) -> Result<(), VersionMismatch>
pub fn compatible_with( &self, engine_version: &ApiVersion, ) -> Result<(), VersionMismatch>
Check compatibility with an engine version.
Returns Ok(()) if major versions match.
Returns a warning string if only the minor differs.
Returns an error if major versions differ.
§Errors
Returns VersionMismatch::Incompatible if self.major != engine_version.major.
Minor version mismatches are accepted with a logged warning
(the caller is expected to handle the log, not this function).
Trait Implementations§
Source§impl Clone for ApiVersion
impl Clone for ApiVersion
Source§fn clone(&self) -> ApiVersion
fn clone(&self) -> ApiVersion
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more