pub trait Section: Send + Sync {
// Required methods
fn section_type(&self) -> SectionType;
fn serialize(&self) -> Result<Vec<u8>>;
fn deserialize(&mut self, data: &[u8]) -> Result<()>;
fn is_dirty(&self) -> bool;
fn mark_clean(&self);
fn memory_usage(&self) -> usize;
// Provided method
fn version(&self) -> u8 { ... }
}Expand description
A serializable section for the .grafeo container.
Implemented in grafeo-core for each data model (LPG, RDF) and index
type (Vector, Text, Ring). The container I/O layer in grafeo-storage
calls serialize() and deserialize() without knowing the section internals.
The unified flush model uses this trait: the engine iterates all sections, serializes dirty ones, and passes the bytes to the container writer.
Required Methods§
Sourcefn section_type(&self) -> SectionType
fn section_type(&self) -> SectionType
The section type identifier.
Sourcefn serialize(&self) -> Result<Vec<u8>>
fn serialize(&self) -> Result<Vec<u8>>
Serialize section contents to bytes.
Called by the flush path (checkpoint, eviction, explicit CHECKPOINT). The returned bytes are opaque to the container writer.
§Errors
Returns an error if serialization fails (e.g., encoding error).
Sourcefn deserialize(&mut self, data: &[u8]) -> Result<()>
fn deserialize(&mut self, data: &[u8]) -> Result<()>
Populate section contents from bytes.
Called during recovery (loading from container) or reload (mmap to RAM).
§Errors
Returns an error if deserialization fails (e.g., corrupt data, version mismatch).
Sourcefn mark_clean(&self)
fn mark_clean(&self)
Mark the section as clean after a successful flush.
Sourcefn memory_usage(&self) -> usize
fn memory_usage(&self) -> usize
Estimated memory usage of this section in bytes.