pub struct WritePayload {
pub id: u64,
pub vector: Vec<f32>,
pub metadata: Vec<u8>,
pub agent_id: [u8; 16],
pub timestamp_ns: u64,
}Expand description
A vector write payload: the unit of admission through a WriteGate.
Fields§
§id: u64Monotonic identifier assigned by the caller.
vector: Vec<f32>The embedding vector (f32 components).
metadata: Vec<u8>Arbitrary metadata bytes (e.g. JSON-encoded tags, namespace, etc.).
agent_id: [u8; 16]Originating agent identifier (16 bytes, e.g. UUID without hyphens).
timestamp_ns: u64UNIX timestamp in nanoseconds at the write site.
Implementations§
Source§impl WritePayload
impl WritePayload
pub fn new(id: u64, vector: Vec<f32>) -> Self
pub fn with_metadata(self, metadata: Vec<u8>) -> Self
pub fn with_agent(self, agent_id: [u8; 16]) -> Self
pub fn with_timestamp(self, timestamp_ns: u64) -> Self
Sourcepub fn payload_hash(&self) -> [u8; 32]
pub fn payload_hash(&self) -> [u8; 32]
SHA-256 of the canonical encoding, computed without allocating the
intermediate byte buffer — streams each field straight into the hasher.
Produces a digest identical to Sha256::digest(self.canonical_bytes()),
so it is a drop-in fast path (no on-disk/format change).
Sourcepub fn canonical_bytes(&self) -> Vec<u8> ⓘ
pub fn canonical_bytes(&self) -> Vec<u8> ⓘ
Canonical byte representation used as hash preimage.
Fixed-structure concatenation: prevents length-extension issues because each field has a deterministic length or delimiter.