pub struct ElementCache { /* private fields */ }Expand description
Element cache for storing collapsed discussion elements (code blocks, details sections, truncated comments, overflow).
Lives entirely in Rust memory. Pure Rust — Python bindings exist
in the sibling mcp-methods-py crate as a thin PyElementCache
newtype wrapping this struct.
Implementations§
Source§impl ElementCache
impl ElementCache
pub fn new() -> Self
Sourcepub fn get(&self, repo: &str, number: u64, element_id: &str) -> Option<String>
pub fn get(&self, repo: &str, number: u64, element_id: &str) -> Option<String>
Get a cached element as a JSON string. Returns None if not found.
Sourcepub fn store_elements(&mut self, repo: &str, number: u64, elements_json: &str)
pub fn store_elements(&mut self, repo: &str, number: u64, elements_json: &str)
Store elements for a repo/number, replacing any existing ones.
Sourcepub fn update_elements(&mut self, repo: &str, number: u64, elements_json: &str)
pub fn update_elements(&mut self, repo: &str, number: u64, elements_json: &str)
Add elements to an existing cache entry (merge).
Sourcepub fn available(&self, repo: &str, number: u64) -> Vec<String>
pub fn available(&self, repo: &str, number: u64) -> Vec<String>
List available element IDs for a repo/number.
Sourcepub fn retrieve(
&self,
repo: &str,
number: u64,
element_id: &str,
lines: Option<&str>,
grep: Option<&str>,
context: usize,
) -> String
pub fn retrieve( &self, repo: &str, number: u64, element_id: &str, lines: Option<&str>, grep: Option<&str>, context: usize, ) -> String
Retrieve a cached element with optional line slicing or grep.
This is the main drill-down method. Returns a JSON string.
Sourcepub fn fetch_issue(
&mut self,
repo: &str,
number: u64,
element_id: Option<&str>,
lines: Option<&str>,
grep: Option<&str>,
context: usize,
refresh: bool,
) -> String
pub fn fetch_issue( &mut self, repo: &str, number: u64, element_id: Option<&str>, lines: Option<&str>, grep: Option<&str>, context: usize, refresh: bool, ) -> String
Fetch a GitHub issue/PR, compact it, and store cache entries.
Releases the GIL during all HTTP and computation (when the
python feature is on). This is the primary entry point for
fetching discussions with caching, callable from both Python
and pure Rust.
Every code path returns a status string — invalid-repo, fetch-
failure, cached-summary, overflow-preview, and full-text are
all returned as String; the return is never a real error
envelope. Pyo3 wraps the return as a Python str when the
python feature is enabled.