pub struct CacheableResult {
pub ttl_ms: f64,
pub cache_scope: CacheScope,
}Expand description
Core MCP protocol types and error handling
Cacheable-result mixin per schema. Embed via #[serde(flatten)]:
ⓘ
pub struct ListToolsResult {
#[serde(default)]
pub result_type: crate::result_type::ResultType,
#[serde(flatten)]
pub cache: crate::caching::CacheableResult,
// ... domain-specific fields ...
}Both fields are REQUIRED on the wire. Constructors should always set them.
Fields§
§ttl_ms: f64Cache lifetime hint in milliseconds.
0means immediately stale; client MAY re-fetch every use.- Positive: client SHOULD consider the result fresh for this many ms.
Schema type is number (@minimum 0) — fractional values are
spec-legal and accepted on deserialize; whole values serialize as
integers so the common case keeps its compact wire form.
cache_scope: CacheScopeSharing scope.
Implementations§
Source§impl CacheableResult
impl CacheableResult
Sourcepub fn new(ttl_ms: f64, cache_scope: CacheScope) -> CacheableResult
pub fn new(ttl_ms: f64, cache_scope: CacheScope) -> CacheableResult
Construct with both required fields.
Sourcepub fn stale_public() -> CacheableResult
pub fn stale_public() -> CacheableResult
Convenience: immediately-stale public response (ttlMs=0, public scope).
Sourcepub fn private_60s() -> CacheableResult
pub fn private_60s() -> CacheableResult
Convenience: 60-second private cache.
Trait Implementations§
Source§impl Clone for CacheableResult
impl Clone for CacheableResult
Source§fn clone(&self) -> CacheableResult
fn clone(&self) -> CacheableResult
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CacheableResult
impl Debug for CacheableResult
Source§impl<'de> Deserialize<'de> for CacheableResult
impl<'de> Deserialize<'de> for CacheableResult
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<CacheableResult, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CacheableResult, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for CacheableResult
impl PartialEq for CacheableResult
Source§impl Serialize for CacheableResult
impl Serialize for CacheableResult
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for CacheableResult
Auto Trait Implementations§
impl Freeze for CacheableResult
impl RefUnwindSafe for CacheableResult
impl Send for CacheableResult
impl Sync for CacheableResult
impl Unpin for CacheableResult
impl UnsafeUnpin for CacheableResult
impl UnwindSafe for CacheableResult
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more