pub trait MatchEngineCache: Sized {
type WireError: Display + Debug;
const WIRE_MAGIC: [u8; 4];
const WIRE_VERSION: u32;
const MAX_CACHE_BYTES: u64 = MAX_MATCH_ENGINE_CACHE_BYTES;
// Required methods
fn to_bytes(&self) -> Result<Vec<u8>, Self::WireError>;
fn from_bytes(bytes: &[u8]) -> Result<Self, Self::WireError>;
}Expand description
Wire serialization for caching a compiled engine. Kept separate
from MatchScan because typed errors aren’t dyn-safe.
Required Associated Constants§
Sourceconst WIRE_MAGIC: [u8; 4]
const WIRE_MAGIC: [u8; 4]
Wire-format magic the engine stamps on every encoded blob. The
contracts test asserts that to_bytes()[0..4] == WIRE_MAGIC
so consumers cannot accidentally forge a cache file with a
different magic and have it silently load.
Sourceconst WIRE_VERSION: u32
const WIRE_VERSION: u32
Wire-format version stamped after the magic. Bumped on any
breaking layout change. The cache helper uses this to discard
blobs from older builds; a VersionMismatch decode error is
the canonical “stale cache, recompile” signal.
Provided Associated Constants§
Sourceconst MAX_CACHE_BYTES: u64 = MAX_MATCH_ENGINE_CACHE_BYTES
const MAX_CACHE_BYTES: u64 = MAX_MATCH_ENGINE_CACHE_BYTES
Largest on-disk cache blob this engine will read back. A blob exceeding
it is treated as oversized (dropped, then recompiled). Defaults to
[MAX_MATCH_ENGINE_CACHE_BYTES]; engines whose compiled form is
genuinely large (e.g. a batched-megakernel DFA catalog, ~GB) override it.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".