Weave documentation
Rust referenceweave-nexus

weave-nexus · view

Source declarations, signatures and documentation for view.

Source: sigil/weave/models/nexus/src/view.rs. SHA-256: dfbabd057e591939b894791f5e2c981f787e6e779db90ac5dca6c6ecad19896b.

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.

view::NexusView

View persistence adapter API

#[async_trait]
pub trait NexusView: Send + Sync {
    /// Append a batch of entries to the persisted view
    async fn append_batch(&self, batch: &[ViewEntry]) -> Result<()>;
}

Source line: 22.

view::NexusViewAdapter

Adapter that opens a concrete persisted view

#[async_trait]
pub trait NexusViewAdapter: Send + Sync {
    async fn open(&self) -> Result<Arc<dyn NexusView>>;
}

Source line: 29.

view::MemoryView

In-memory no-op view for tests and non-persistent deployments

pub struct MemoryView;

Source line: 34.

view::StrandView

Strand-backed persistent view

pub struct StrandView {

}

Source line: 44.

view::StrandView::new

pub fn new(strand: Arc<tokio::sync::Mutex<Strand>>) -> Self;

Source line: 49.

view::StrandViewAdapter

Adapter opening a Strand-backed view

pub struct StrandViewAdapter {

}

Source line: 72.

view::StrandViewAdapter::new

pub fn new(strand: Arc<tokio::sync::Mutex<Strand>>) -> Self;

Source line: 77.

view::NexusCursor

Opaque pagination cursor (encodes an offset)

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct NexusCursor(pub Vec<u8>);

Source line: 90.

view::NexusCursor::from_offset

pub fn from_offset(offset: usize) -> Self;

Source line: 93.

view::NexusCursor::to_offset

pub fn to_offset(&self) -> usize;

Source line: 96.

view::Page

Page result for view pagination

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Page {
pub items: Vec<ViewEntry>,
pub next: Option<NexusCursor>,
pub prev: Option<NexusCursor>,
pub total: usize
}

Source line: 106.

view::ViewEntry

Entry in a linearized view

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ViewEntry {
/// Which agent produced this entry

pub source_agent: String,
/// Index in the source strand

pub source_index: u64,
/// Entry data

pub data: Vec<u8>,
/// Timestamp from source strand

pub timestamp: SystemTime,
/// Optional metadata

pub metadata: Option<ViewMetadata>
}

Source line: 115.

view::ViewMetadata

Metadata for view entries

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ViewMetadata {
/// Hash of the entry

pub hash: [u8; 32],
/// Size in bytes

pub size: u64,
/// Custom application metadata

pub app_metadata: Option<Vec<u8>>
}

Source line: 134.

view::ViewMetadata::from_data

Create metadata from data

pub fn from_data(data: &[u8], app_metadata: Option<Vec<u8>>) -> Self;

Source line: 147.

view::ViewManager

Manages the linearized view of multiple strands

pub struct ViewManager {

}

Source line: 157.

view::ViewManager::new

Create a new view manager

pub fn new(ordering: Box<dyn OrderingStrategy>) -> Self;

Source line: 180.

view::ViewManager::attach_view_strand

Attach a read-only Strand as an indexable view backing store

pub fn attach_view_strand(&self, strand: Arc<Strand>);

Source line: 195.

view::ViewManager::has_view_strand

Check if a view strand is attached

pub fn has_view_strand(&self) -> bool;

Source line: 200.

view::ViewManager::set_sink

Install a persistence sink

pub fn set_sink(&self, sink: Arc<dyn NexusView>);

Source line: 205.

view::ViewManager::current_view

Get current view

pub fn current_view(&self) -> Vec<ViewEntry>;

Source line: 217.

view::ViewManager::len

Get view length

pub fn len(&self) -> usize;

Source line: 222.

view::ViewManager::is_empty

Check if view is empty

pub fn is_empty(&self) -> bool;

Source line: 227.

view::ViewManager::last_update

Get last update time

pub fn last_update(&self) -> SystemTime;

Source line: 232.

view::ViewManager::add_entries

Add new entries incrementally

pub fn add_entries(
        &mut self,
        new_entries: Vec<UnorderedEntry>,
    ) -> Result<Option<PersistBatch>>;

Source line: 237.

view::ViewManager::regenerate_view

Generate view from scratch

pub fn regenerate_view(
        &mut self,
        all_entries: Vec<UnorderedEntry>,
    ) -> Result<Option<PersistBatch>>;

Source line: 270.

view::ViewManager::get_range

Get entries in a range

pub fn get_range(&self, start: usize, end: usize) -> Vec<ViewEntry>;

Source line: 299.

view::ViewManager::paginate

Paginate current view using cursor+limit

pub fn paginate(&self, cursor: Option<NexusCursor>, limit: usize) -> Page;

Source line: 311.

view::ViewManager::find_by_agent

Find entries by agent

pub fn find_by_agent(&self, agent_did: &str) -> Vec<ViewEntry>;

Source line: 347.

view::ViewManager::metrics

Metrics snapshot

pub fn metrics(&self) -> ViewMetrics;

Source line: 357.

view::ViewMetrics

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ViewMetrics {
pub applied_batches_total: u64,
pub applied_entries_total: u64,
pub applied_bytes_total: u64,
pub apply_latency_ms_hist: Vec<u64>
}

Source line: 368.

view::ViewStrategy

Strategy for generating views

#[async_trait]
pub trait ViewStrategy: Send + Sync {
    /// Generate view from input strands
    async fn generate_view(&self, entries: Vec<UnorderedEntry>) -> Result<Vec<ViewEntry>>;

    /// Strategy name
    fn name(&self) -> &str;
}

Source line: 377.

On this page