Skip to main content

Meta

Struct Meta 

Source
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

Source

pub fn new() -> Meta

Available on non-target_family=wasm only.
Source

pub fn with_progress_token(token: ProgressToken) -> Meta

Available on non-target_family=wasm only.

Create a new Meta with a progress token set

Source

pub fn get_progress_token(&self) -> Option<ProgressToken>

Available on non-target_family=wasm only.
Source

pub fn set_progress_token(&mut self, token: ProgressToken)

Available on non-target_family=wasm only.
Source

pub fn protocol_version(&self) -> Option<ProtocolVersion>

Available on non-target_family=wasm only.

Get the MCP protocol version carried in _meta, if present and valid.

Source

pub fn set_protocol_version(&mut self, protocol_version: ProtocolVersion)

Available on non-target_family=wasm only.

Set the MCP protocol version carried in _meta.

Source

pub fn client_info(&self) -> Option<Implementation>

Available on non-target_family=wasm only.

Get the client implementation identity carried in _meta, if present and valid.

Source

pub fn set_client_info(&mut self, client_info: Implementation)

Available on non-target_family=wasm only.

Set the client implementation identity carried in _meta.

Source

pub fn client_capabilities(&self) -> Option<ClientCapabilities>

Available on non-target_family=wasm only.

Get the client capabilities carried in _meta, if present and valid.

Source

pub fn set_client_capabilities( &mut self, client_capabilities: ClientCapabilities, )

Available on non-target_family=wasm only.

Set the client capabilities carried in _meta.

Source

pub fn log_level(&self) -> Option<LoggingLevel>

Available on non-target_family=wasm only.

Get the requested per-request log level carried in _meta, if present and valid.

Source

pub fn set_log_level(&mut self, log_level: LoggingLevel)

Available on non-target_family=wasm only.

Set the requested per-request log level carried in _meta.

Source

pub fn get_traceparent(&self) -> Option<&str>

Available on non-target_family=wasm only.

Get the W3C traceparent value (SEP-414), if present.

Source

pub fn set_traceparent(&mut self, value: impl Into<String>)

Available on non-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"),
);
Source

pub fn get_tracestate(&self) -> Option<&str>

Available on non-target_family=wasm only.

Get the W3C tracestate value (SEP-414), if present.

Source

pub fn set_tracestate(&mut self, value: impl Into<String>)

Available on non-target_family=wasm only.

Set the W3C tracestate value (SEP-414).

Source

pub fn get_baggage(&self) -> Option<&str>

Available on non-target_family=wasm only.

Get the W3C baggage value (SEP-414), if present.

Source

pub fn set_baggage(&mut self, value: impl Into<String>)

Available on non-target_family=wasm only.

Set the W3C baggage value (SEP-414).

Source

pub fn extend(&mut self, other: Meta)

Available on non-target_family=wasm only.

Methods from Deref<Target = Map<String, Value>>§

Source

pub fn clear(&mut self)

Clears the map, removing all values.

Source

pub fn get<Q>(&self, key: &Q) -> Option<&Value>
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

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.

Source

pub fn contains_key<Q>(&self, key: &Q) -> bool
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

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.

Source

pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut Value>
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

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.

Source

pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&String, &Value)>
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

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.

Source

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.

Source

pub fn shift_insert( &mut self, index: usize, k: String, v: Value, ) -> Option<Value>

Available on crate feature 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.

Source

pub fn remove<Q>(&mut self, key: &Q) -> Option<Value>
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

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.

Source

pub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(String, Value)>
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

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.

Source

pub fn swap_remove<Q>(&mut self, key: &Q) -> Option<Value>
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

Available on crate feature 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!

Source

pub fn swap_remove_entry<Q>(&mut self, key: &Q) -> Option<(String, Value)>
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

Available on crate feature 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!

Source

pub fn shift_remove<Q>(&mut self, key: &Q) -> Option<Value>
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

Available on crate feature 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!

Source

pub fn shift_remove_entry<Q>(&mut self, key: &Q) -> Option<(String, Value)>
where String: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,

Available on crate feature 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!

Source

pub fn append(&mut self, other: &mut Map<String, Value>)

Moves all elements from other into self, leaving other empty.

Source

pub fn entry<S>(&mut self, key: S) -> Entry<'_>
where S: Into<String>,

Gets the given key’s corresponding entry in the map for in-place manipulation.

Source

pub fn len(&self) -> usize

Returns the number of elements in the map.

Source

pub fn is_empty(&self) -> bool

Returns true if the map contains no elements.

Source

pub fn iter(&self) -> Iter<'_> ⓘ

Gets an iterator over the entries of the map.

Source

pub fn iter_mut(&mut self) -> IterMut<'_> ⓘ

Gets a mutable iterator over the entries of the map.

Source

pub fn keys(&self) -> Keys<'_> ⓘ

Gets an iterator over the keys of the map.

Source

pub fn values(&self) -> Values<'_> ⓘ

Gets an iterator over the values of the map.

Source

pub fn values_mut(&mut self) -> ValuesMut<'_> ⓘ

Gets an iterator over mutable values of the map.

Source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&String, &mut Value) -> bool,

Retains only the elements specified by the predicate.

In other words, remove all pairs (k, v) such that f(&k, &mut v) returns false.

Source

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).

Trait Implementations§

Source§

impl Clone for Meta

Source§

fn clone(&self) -> Meta

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Meta

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Meta

Source§

fn default() -> Meta

Returns the “default value” for a type. Read more
Source§

impl Deref for Meta

Source§

type Target = Map<String, Value>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<Meta as Deref>::Target

Dereferences the value.
Source§

impl DerefMut for Meta

Source§

fn deref_mut(&mut self) -> &mut <Meta as Deref>::Target

Mutably dereferences the value.
Source§

impl<'de> Deserialize<'de> for Meta

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Meta, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<C> FromContextPart<C> for Meta

Source§

impl PartialEq for Meta

Source§

fn eq(&self, other: &Meta) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Meta

Source§

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
Source§

impl StructuralPartialEq for Meta

Auto Trait Implementations§

§

impl Freeze for Meta

§

impl RefUnwindSafe for Meta

§

impl Send for Meta

§

impl Sync for Meta

§

impl Unpin for Meta

§

impl UnsafeUnpin for Meta

§

impl UnwindSafe for Meta

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoToolOutput for T
where T: Serialize + 'static,

Source§

fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>

Convert this value without routing structured data through a string.
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more