pub struct WalEntry {
pub model_name: String,
pub operation: WalOperation,
}Expand description
A complete WAL entry: a model-name routing tag plus an operation.
The model_name field is an opaque string stored verbatim in the entry
header. The WAL never interprets it. Generated code uses it to route
replayed entries back to the correct model; ForgeDB itself never branches
on it.
Fields§
§model_name: String§operation: WalOperationImplementations§
Source§impl WalEntry
impl WalEntry
Sourcepub fn raw(model_name: impl Into<String>, payload: Vec<u8>) -> Self
pub fn raw(model_name: impl Into<String>, payload: Vec<u8>) -> Self
Create a raw opaque-bytes entry.
model_name is an opaque routing/debug tag stored verbatim in the
entry header. The WAL never interprets it. The generated caller uses it
to identify which model a replayed entry belongs to.
payload is stored verbatim and returned byte-identical on replay. The
WAL neither inspects nor encodes the payload — the caller owns the
encoding entirely.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialize the entry to bytes including the CRC32 checksum.
Wire format (see lib.rs for the full layout comment):
[4: total_length][1: op_type][2: model_name_len][N: model_name][M: op_data][4: crc32]
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<(Self, usize)>
pub fn from_bytes(bytes: &[u8]) -> Result<(Self, usize)>
Deserialize an entry from a byte slice.
Returns (entry, bytes_consumed) on success. Returns an error on
truncation (torn tail) or CRC mismatch.