Skip to main content

ResultCache

Trait ResultCache 

Source
pub trait ResultCache: Send + Sync {
    // Required methods
    fn store(&self, items: Vec<Value>) -> CachedResultHandle;
    fn page(
        &self,
        handle: &CachedResultHandle,
        offset: usize,
        limit: usize,
    ) -> Option<Vec<Value>>;
    fn len(&self, handle: &CachedResultHandle) -> Option<usize>;
    fn release(&self, handle: &CachedResultHandle) -> bool;
}
Expand description

Transport-neutral cache for paged tool results.

Implementations MUST be safe to share across tasks (Send + Sync). Pagination uses (offset, limit) semantics: page(handle, 0, n) returns up to the first n items. Implementations may serve fewer items than requested if the offset is near the end.

Required Methods§

Source

fn store(&self, items: Vec<Value>) -> CachedResultHandle

Store items and return the handle the caller should publish.

Source

fn page( &self, handle: &CachedResultHandle, offset: usize, limit: usize, ) -> Option<Vec<Value>>

Return up to limit items starting at offset. Returns None if the handle has been released or never existed; returns Some(empty) if the offset is past the end.

Source

fn len(&self, handle: &CachedResultHandle) -> Option<usize>

Total item count for handle, or None if missing.

Source

fn release(&self, handle: &CachedResultHandle) -> bool

Release the handle. Returns true if it existed.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§