Weave documentation
Rust referenceweave-lens

weave-lens · lens

Source declarations, signatures and documentation for lens.

Reviewed implementation boundary: The current batching helper rejects multiple operations instead of implementing atomic batch commits. Cache/compaction/retention configuration fields do not establish running background compaction. See /libraries/lens/overview.

Source: sigil/weave/models/lens/src/lens.rs. SHA-256: ff629e904dc5d97aaea0d8f7ba8f962eecd443de8bc12965b3adcdbb98434cdf.

This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.

lens::Lens

Lens database built on top of Strand

pub struct Lens {
/// Tree metadata

pub metadata: Arc<RwLock<Metadata>>
}

Source line: 48.

lens::Metadata

Tree metadata

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Metadata {
/// B-tree order (max children per node)

pub order: usize,
/// Current root block index

pub root: Option<u64>,
/// Total number of entries

pub entries: u64,
/// Schema version

pub _version: u32,
/// Tree depth

pub depth: u32
}

Source line: 77.

lens::Lens::new

Create a new Lens database (identity-agnostic)

pub async fn new(strand: Arc<AsyncRwLock<Strand>>, config: LensConfig) -> Result<Self>;

Source line: 136.

lens::Lens::get

Get a value by key

pub async fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>>;

Source line: 357.

lens::Lens::put

Put a key-value pair

pub async fn put(&self, key: &[u8], value_bytes: &[u8]) -> Result<()>;

Source line: 375.

lens::Lens::delete

Delete a key

pub async fn delete(&self, key: &[u8]) -> Result<()>;

Source line: 459.

lens::Lens::batch

Apply a batch of operations atomically

pub async fn batch(&self, batch: &Batch) -> Result<()>;

Source line: 514.

lens::Lens::create_read_stream

Create a read stream for range queries

pub async fn create_read_stream(
        &self,
        start: Option<&[u8]>,
        end: Option<&[u8]>,
    ) -> Result<ReadStream>;

Source line: 546.

lens::Lens::create_read_stream_with_options

Create a read stream with options

pub async fn create_read_stream_with_options(
        &self,
        start: Option<&[u8]>,
        end: Option<&[u8]>,
        options: ReadOptions,
    ) -> Result<ReadStream>;

Source line: 556.

lens::Lens::snapshot

Create a snapshot

pub async fn snapshot(&self) -> Result<SnapshotId>;

Source line: 583.

lens::Lens::snapshot_with_name

Create a named snapshot

pub async fn snapshot_with_name(&self, name: String) -> Result<SnapshotId>;

Source line: 612.

lens::Lens::strand_handle

Expose a handle to the underlying strand for advanced operations (e.g., replication)

pub fn strand_handle(&self) -> Arc<AsyncRwLock<Strand>>;

Source line: 642.

lens::Lens::strand_for_replication

Get the underlying strand for replication announcements.

This extracts the Strand from the async lock wrapper.

pub async fn strand_for_replication(&self) -> Arc<tokio::sync::RwLock<Strand>>;

Source line: 649.

lens::Lens::metrics_snapshot

Get a snapshot of Lens telemetry metrics

pub fn metrics_snapshot(&self) -> crate::metrics::LensMetricsSnapshot;

Source line: 656.

lens::Lens::get_snapshot

Get a snapshot by ID

pub fn get_snapshot(&self, id: &SnapshotId) -> Option<Snapshot>;

Source line: 661.

lens::Lens::delete_snapshot

Delete a snapshot

pub fn delete_snapshot(&self, id: &SnapshotId) -> Result<()>;

Source line: 666.

lens::Lens::sub

Create a sub-database

pub fn sub(&self, name: &str) -> SubDatabase;

Source line: 674.

lens::Lens::sub_with_options

Create a sub-database with options

pub fn sub_with_options(&self, name: &str, options: SubOptions) -> SubDatabase;

Source line: 683.

lens::Lens::cache_stats

Get cache statistics

pub fn cache_stats(&self) -> crate::CacheStats;

Source line: 688.

lens::Lens::clear_cache

Clear the cache

pub fn clear_cache(&self);

Source line: 693.

lens::Lens::load_node

Load a node from strand

pub async fn load_node(&self, index: u64) -> Result<Node>;

Source line: 939.

lens::Lens::open_for_replication

Create a read-only strand for replication purposes.

This creates a fresh Strand instance using the same storage and public key as the underlying strand, suitable for announcing on DHT.

pub async fn open_for_replication(&self) -> Result<Arc<strand::Strand>>;

Source line: 1043.

On this page