pub fn encode_as(layer: &Layer, dim: usize, version: u32) -> Result<Bytes>Expand description
Encode a layer as a segment object of version (1, 2 or 3) for vectors of
length dim, with attributes stored as JSON. At version 3 that is the
layout of a free-form namespace; a typed namespace’s segments are what
encode_with_schema writes.
The result depends only on the layer’s contents, not on the order things were inserted. The caller decides whether tombstones belong: a base segment (range starting at 1) should have had them dropped first.
§Errors
ItzmaError::UnsupportedFormatfor any otherversion.ItzmaError::DimensionMismatchif any document’s vector is notdimlong, so a hand-edited WAL cannot produce a corrupt segment.ItzmaError::Serde/ItzmaError::CorruptSegmentif an attribute cannot be serialized or a field is longer than 4 GiB.