pub struct Meta(pub Map<String, Value>);Expand description
Re-export of rmcp::model::Meta: wrap one in McpMeta and place it
in the per-call ToolContext to have MCP tools forward it as the
request’s _meta.
Tuple Fields§
§0: Map<String, Value>Implementations§
Source§impl Meta
impl Meta
pub fn new() -> Meta
target_family=wasm only.Sourcepub fn with_progress_token(token: ProgressToken) -> Meta
Available on non-target_family=wasm only.
pub fn with_progress_token(token: ProgressToken) -> Meta
target_family=wasm only.Create a new Meta with a progress token set
pub fn get_progress_token(&self) -> Option<ProgressToken>
target_family=wasm only.pub fn set_progress_token(&mut self, token: ProgressToken)
target_family=wasm only.Sourcepub fn protocol_version(&self) -> Option<ProtocolVersion>
Available on non-target_family=wasm only.
pub fn protocol_version(&self) -> Option<ProtocolVersion>
target_family=wasm only.Get the MCP protocol version carried in _meta, if present and valid.
Sourcepub fn set_protocol_version(&mut self, protocol_version: ProtocolVersion)
Available on non-target_family=wasm only.
pub fn set_protocol_version(&mut self, protocol_version: ProtocolVersion)
target_family=wasm only.Set the MCP protocol version carried in _meta.
Sourcepub fn client_info(&self) -> Option<Implementation>
Available on non-target_family=wasm only.
pub fn client_info(&self) -> Option<Implementation>
target_family=wasm only.Get the client implementation identity carried in _meta, if present and valid.
Sourcepub fn set_client_info(&mut self, client_info: Implementation)
Available on non-target_family=wasm only.
pub fn set_client_info(&mut self, client_info: Implementation)
target_family=wasm only.Set the client implementation identity carried in _meta.
Sourcepub fn client_capabilities(&self) -> Option<ClientCapabilities>
Available on non-target_family=wasm only.
pub fn client_capabilities(&self) -> Option<ClientCapabilities>
target_family=wasm only.Get the client capabilities carried in _meta, if present and valid.
Sourcepub fn set_client_capabilities(
&mut self,
client_capabilities: ClientCapabilities,
)
Available on non-target_family=wasm only.
pub fn set_client_capabilities( &mut self, client_capabilities: ClientCapabilities, )
target_family=wasm only.Set the client capabilities carried in _meta.
Sourcepub fn log_level(&self) -> Option<LoggingLevel>
Available on non-target_family=wasm only.
pub fn log_level(&self) -> Option<LoggingLevel>
target_family=wasm only.Get the requested per-request log level carried in _meta, if present and valid.
Sourcepub fn set_log_level(&mut self, log_level: LoggingLevel)
Available on non-target_family=wasm only.
pub fn set_log_level(&mut self, log_level: LoggingLevel)
target_family=wasm only.Set the requested per-request log level carried in _meta.
Sourcepub fn get_traceparent(&self) -> Option<&str>
Available on non-target_family=wasm only.
pub fn get_traceparent(&self) -> Option<&str>
target_family=wasm only.Get the W3C traceparent value (SEP-414), if present.
Sourcepub fn set_traceparent(&mut self, value: impl Into<String>)
Available on non-target_family=wasm only.
pub fn set_traceparent(&mut self, value: impl Into<String>)
target_family=wasm only.Set the W3C traceparent value (SEP-414).
use rmcp::model::Meta;
let mut meta = Meta::new();
meta.set_traceparent("00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-01");
assert_eq!(
meta.get_traceparent(),
Some("00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-01"),
);Sourcepub fn get_tracestate(&self) -> Option<&str>
Available on non-target_family=wasm only.
pub fn get_tracestate(&self) -> Option<&str>
target_family=wasm only.Get the W3C tracestate value (SEP-414), if present.
Sourcepub fn set_tracestate(&mut self, value: impl Into<String>)
Available on non-target_family=wasm only.
pub fn set_tracestate(&mut self, value: impl Into<String>)
target_family=wasm only.Set the W3C tracestate value (SEP-414).
Sourcepub fn get_baggage(&self) -> Option<&str>
Available on non-target_family=wasm only.
pub fn get_baggage(&self) -> Option<&str>
target_family=wasm only.Get the W3C baggage value (SEP-414), if present.
Sourcepub fn set_baggage(&mut self, value: impl Into<String>)
Available on non-target_family=wasm only.
pub fn set_baggage(&mut self, value: impl Into<String>)
target_family=wasm only.Set the W3C baggage value (SEP-414).
pub fn extend(&mut self, other: Meta)
target_family=wasm only.Methods from Deref<Target = Map<String, Value>>§
Sourcepub fn get<Q>(&self, key: &Q) -> Option<&Value>
pub fn get<Q>(&self, key: &Q) -> Option<&Value>
Returns a reference to the value corresponding to the key.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
Sourcepub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Returns true if the map contains a value for the specified key.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
Sourcepub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut Value>
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut Value>
Returns a mutable reference to the value corresponding to the key.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
Sourcepub fn get_key_value<Q>(&self, key: &Q) -> Option<(&String, &Value)>
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&String, &Value)>
Returns the key-value pair matching the given key.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
Sourcepub fn insert(&mut self, k: String, v: Value) -> Option<Value>
pub fn insert(&mut self, k: String, v: Value) -> Option<Value>
Inserts a key-value pair into the map.
If the map did not have this key present, None is returned.
If the map did have this key present, the value is updated, and the old value is returned.
Sourcepub fn shift_insert(
&mut self,
index: usize,
k: String,
v: Value,
) -> Option<Value>
Available on crate feature preserve_order only.
pub fn shift_insert( &mut self, index: usize, k: String, v: Value, ) -> Option<Value>
preserve_order only.Insert a key-value pair in the map at the given index.
If the map did not have this key present, None is returned.
If the map did have this key present, the key is moved to the new position, the value is updated, and the old value is returned.
Sourcepub fn remove<Q>(&mut self, key: &Q) -> Option<Value>
pub fn remove<Q>(&mut self, key: &Q) -> Option<Value>
Removes a key from the map, returning the value at the key if the key was previously in the map.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
If serde_json’s “preserve_order” is enabled, .remove(key) is
equivalent to .swap_remove(key), replacing this
entry’s position with the last element. If you need to preserve the
relative order of the keys in the map, use
.shift_remove(key) instead.
Sourcepub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(String, Value)>
pub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(String, Value)>
Removes a key from the map, returning the stored key and value if the key was previously in the map.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
If serde_json’s “preserve_order” is enabled, .remove_entry(key) is
equivalent to .swap_remove_entry(key),
replacing this entry’s position with the last element. If you need to
preserve the relative order of the keys in the map, use
.shift_remove_entry(key) instead.
Sourcepub fn swap_remove<Q>(&mut self, key: &Q) -> Option<Value>
Available on crate feature preserve_order only.
pub fn swap_remove<Q>(&mut self, key: &Q) -> Option<Value>
preserve_order only.Removes and returns the value corresponding to the key from the map.
Like Vec::swap_remove, the entry is removed by swapping it with the
last element of the map and popping it off. This perturbs the position
of what used to be the last element!
Sourcepub fn swap_remove_entry<Q>(&mut self, key: &Q) -> Option<(String, Value)>
Available on crate feature preserve_order only.
pub fn swap_remove_entry<Q>(&mut self, key: &Q) -> Option<(String, Value)>
preserve_order only.Remove and return the key-value pair.
Like Vec::swap_remove, the entry is removed by swapping it with the
last element of the map and popping it off. This perturbs the position
of what used to be the last element!
Sourcepub fn shift_remove<Q>(&mut self, key: &Q) -> Option<Value>
Available on crate feature preserve_order only.
pub fn shift_remove<Q>(&mut self, key: &Q) -> Option<Value>
preserve_order only.Removes and returns the value corresponding to the key from the map.
Like Vec::remove, the entry is removed by shifting all of the
elements that follow it, preserving their relative order. This perturbs
the index of all of those elements!
Sourcepub fn shift_remove_entry<Q>(&mut self, key: &Q) -> Option<(String, Value)>
Available on crate feature preserve_order only.
pub fn shift_remove_entry<Q>(&mut self, key: &Q) -> Option<(String, Value)>
preserve_order only.Remove and return the key-value pair.
Like Vec::remove, the entry is removed by shifting all of the
elements that follow it, preserving their relative order. This perturbs
the index of all of those elements!
Sourcepub fn append(&mut self, other: &mut Map<String, Value>)
pub fn append(&mut self, other: &mut Map<String, Value>)
Moves all elements from other into self, leaving other empty.
Sourcepub fn entry<S>(&mut self, key: S) -> Entry<'_>
pub fn entry<S>(&mut self, key: S) -> Entry<'_>
Gets the given key’s corresponding entry in the map for in-place manipulation.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_> ⓘ
Gets a mutable iterator over the entries of the map.
Sourcepub fn values_mut(&mut self) -> ValuesMut<'_> ⓘ
pub fn values_mut(&mut self) -> ValuesMut<'_> ⓘ
Gets an iterator over mutable values of the map.
Sourcepub fn retain<F>(&mut self, f: F)
pub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
In other words, remove all pairs (k, v) such that f(&k, &mut v)
returns false.
Sourcepub fn sort_keys(&mut self)
pub fn sort_keys(&mut self)
Sorts this map’s entries in-place using str’s usual ordering.
If serde_json’s “preserve_order” feature is not enabled, this method does no work because all JSON maps are always kept in a sorted state.
If serde_json’s “preserve_order” feature is enabled, this method destroys the original source order or insertion order of this map in favor of an alphanumerical order that matches how a BTreeMap with the same contents would be ordered. This takes O(n log n + c) time where n is the length of the map and c is the capacity.
Other maps nested within the values of this map are not sorted. If you
need the entire data structure to be sorted at all levels, you must also
call
map.values_mut().for_each(Value::sort_all_objects).