@@ -1142,6 +1142,18 @@ pub type ProgressNotification = Notification<ProgressNotificationMethod, Progres
11421142
11431143pub type Cursor = String ;
11441144
1145+ /// Scope describing who may cache cacheable list/read results.
1146+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq , Eq ) ]
1147+ #[ serde( rename_all = "camelCase" ) ]
1148+ #[ cfg_attr( feature = "schemars" , derive( schemars:: JsonSchema ) ) ]
1149+ #[ non_exhaustive]
1150+ pub enum CacheScope {
1151+ /// The response may be cached for the current user.
1152+ User ,
1153+ /// The response may be shared by clients with equivalent authorization.
1154+ Shared ,
1155+ }
1156+
11451157macro_rules! paginated_result {
11461158 ( $t: ident {
11471159 $i_item: ident: $t_item: ty
@@ -1155,19 +1167,35 @@ macro_rules! paginated_result {
11551167 pub meta: Option <Meta >,
11561168 #[ serde( skip_serializing_if = "Option::is_none" ) ]
11571169 pub next_cursor: Option <Cursor >,
1170+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
1171+ pub ttl_ms: Option <u64 >,
1172+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
1173+ pub cache_scope: Option <CacheScope >,
11581174 pub $i_item: $t_item,
11591175 }
11601176
11611177 impl $t {
1162- pub fn with_all_items(
1163- items: $t_item,
1164- ) -> Self {
1178+ pub fn with_all_items( items: $t_item) -> Self {
11651179 Self {
11661180 meta: None ,
11671181 next_cursor: None ,
1182+ ttl_ms: None ,
1183+ cache_scope: None ,
11681184 $i_item: items,
11691185 }
11701186 }
1187+
1188+ /// Set the time, in milliseconds, that this result may be treated as fresh.
1189+ pub fn with_ttl_ms( mut self , ttl_ms: u64 ) -> Self {
1190+ self . ttl_ms = Some ( ttl_ms) ;
1191+ self
1192+ }
1193+
1194+ /// Set the cache scope for this result.
1195+ pub fn with_cache_scope( mut self , cache_scope: CacheScope ) -> Self {
1196+ self . cache_scope = Some ( cache_scope) ;
1197+ self
1198+ }
11711199 }
11721200 } ;
11731201}
@@ -1239,17 +1267,40 @@ pub type ReadResourceRequestParam = ReadResourceRequestParams;
12391267
12401268/// Result containing the contents of a read resource
12411269#[ derive( Debug , Serialize , Deserialize , Clone , PartialEq ) ]
1270+ #[ serde( rename_all = "camelCase" ) ]
12421271#[ cfg_attr( feature = "schemars" , derive( schemars:: JsonSchema ) ) ]
12431272#[ non_exhaustive]
12441273pub struct ReadResourceResult {
12451274 /// The actual content of the resource
12461275 pub contents : Vec < ResourceContents > ,
1276+ /// Time, in milliseconds, that this result may be treated as fresh.
1277+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
1278+ pub ttl_ms : Option < u64 > ,
1279+ /// Scope describing who may cache this result.
1280+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
1281+ pub cache_scope : Option < CacheScope > ,
12471282}
12481283
12491284impl ReadResourceResult {
12501285 /// Create a new ReadResourceResult with the given contents.
12511286 pub fn new ( contents : Vec < ResourceContents > ) -> Self {
1252- Self { contents }
1287+ Self {
1288+ contents,
1289+ ttl_ms : None ,
1290+ cache_scope : None ,
1291+ }
1292+ }
1293+
1294+ /// Set the time, in milliseconds, that this result may be treated as fresh.
1295+ pub fn with_ttl_ms ( mut self , ttl_ms : u64 ) -> Self {
1296+ self . ttl_ms = Some ( ttl_ms) ;
1297+ self
1298+ }
1299+
1300+ /// Set the cache scope for this result.
1301+ pub fn with_cache_scope ( mut self , cache_scope : CacheScope ) -> Self {
1302+ self . cache_scope = Some ( cache_scope) ;
1303+ self
12531304 }
12541305}
12551306
0 commit comments