Skip to main content

Section

Trait Section 

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

Source

fn section_type(&self) -> SectionType

The section type identifier.

Source

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).

Source

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).

Source

fn is_dirty(&self) -> bool

Whether this section has been modified since the last flush.

Source

fn mark_clean(&self)

Mark the section as clean after a successful flush.

Source

fn memory_usage(&self) -> usize

Estimated memory usage of this section in bytes.

Provided Methods§

Source

fn version(&self) -> u8

Per-section format version.

Implementors§