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§
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] ⓘ
Sourcefn remove_segments(&mut self, segment_ids: &[SegmentId])
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.
Sourcefn write_vector_index(&mut self, field_id: FieldId, data: &[u8]) -> Result<()>
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]].
Sourcefn read_vector_index(&self, field_id: FieldId) -> Result<Option<Vec<u8>>>
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.
Sourcefn vector_index_fields(&self) -> Vec<FieldId>
fn vector_index_fields(&self) -> Vec<FieldId>
List the fields that have a committed vector index.
Sourcefn remove_vector_index(&mut self, field_id: FieldId)
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§
Sourcefn set_write_timeout(&mut self, _timeout: Duration)
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".