Skip to main content

MatchEngineCache

Trait MatchEngineCache 

Source
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§

Source

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.

Source

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§

Source

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§

Source

type WireError: Display + Debug

The engine’s wire-error enum. Forwarded to the cache helper so load failures discriminate “stale cache, recompile” from “real bug, refuse to start”.

Required Methods§

Source

fn to_bytes(&self) -> Result<Vec<u8>, Self::WireError>

Encode the compiled engine for on-disk caching.

§Errors

Engine-specific framing error.

Source

fn from_bytes(bytes: &[u8]) -> Result<Self, Self::WireError>

Decode a previously-cached engine.

§Errors

Engine-specific framing error. The cache helper treats every WireError as “stale, drop and recompile” - that’s the designed-in semantics.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§