Skip to main content

Storage

Trait Storage 

Source
pub trait Storage: Send {
Show 13 methods // Required methods fn write_segment( &mut self, segment_id: SegmentId, data: &[u8], ) -> Result<()>; fn read_segment(&self, segment_id: SegmentId) -> Result<Vec<u8>>; fn commit(&mut self) -> Result<()>; fn segments(&self) -> &[SegmentEntry]; fn generation(&self) -> u64; fn set_user_metadata(&mut self, metadata: Vec<u8>); fn user_metadata(&self) -> &[u8] ; fn remove_segments(&mut self, segment_ids: &[SegmentId]); fn write_vector_index( &mut self, field_id: FieldId, data: &[u8], ) -> Result<()>; fn read_vector_index(&self, field_id: FieldId) -> Result<Option<Vec<u8>>>; fn vector_index_fields(&self) -> Vec<FieldId>; fn remove_vector_index(&mut self, field_id: FieldId); // Provided method fn set_write_timeout(&mut self, _timeout: Duration) { ... }
}
Expand description

Trait abstracting over storage backends.

SingleFileDirectory is the sole implementation today. The trait exists so that consumers (IndexReader, the index writer, etc.) depend on a stable storage interface rather than a concrete type.

Required Methods§

Source

fn write_segment(&mut self, segment_id: SegmentId, data: &[u8]) -> Result<()>

Source

fn read_segment(&self, segment_id: SegmentId) -> Result<Vec<u8>>

Source

fn commit(&mut self) -> Result<()>

Source

fn segments(&self) -> &[SegmentEntry]

Source

fn generation(&self) -> u64

Source

fn set_user_metadata(&mut self, metadata: Vec<u8>)

Source

fn user_metadata(&self) -> &[u8]

Source

fn remove_segments(&mut self, segment_ids: &[SegmentId])

Mark segments for removal on the next commit. Their storage space is reclaimed when the commit completes.

Source

fn write_vector_index(&mut self, field_id: FieldId, data: &[u8]) -> Result<()>

Write a per-field vector index (e.g., serialized HNSW graph) as an index-wide artifact, separate from segments. Replaces any previously-committed bytes for the same field_id on next commit. See [[global-vector-indices]].

Source

fn read_vector_index(&self, field_id: FieldId) -> Result<Option<Vec<u8>>>

Read the committed bytes for a per-field vector index. Returns None if no index exists for that field.

Source

fn vector_index_fields(&self) -> Vec<FieldId>

List the fields that have a committed vector index.

Source

fn remove_vector_index(&mut self, field_id: FieldId)

Mark the vector index for field_id for removal on the next commit. No-op if the field has no committed index.

Provided Methods§

Source

fn set_write_timeout(&mut self, _timeout: Duration)

Set the timeout for acquiring the cross-process write lock.

Default: 5 seconds.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Storage for SingleFileDirectory

Available on Unix only.