pub struct ResourceSubscriptions(/* private fields */);Expand description
Tracks which MCP resource URIs the client has subscribed to.
The hot read path (pump tasks checking before sending notifications) uses
a RwLock so concurrent readers do not block each other.
Implementations§
Source§impl ResourceSubscriptions
impl ResourceSubscriptions
Sourcepub async fn subscribe(&self, uri: String) -> Result<bool, String>
pub async fn subscribe(&self, uri: String) -> Result<bool, String>
Add a URI to the subscription set.
Returns Ok(true) if newly inserted, Ok(false) if already present.
Returns Err if the subscription set has reached MAX_SUBSCRIPTIONS.
§Errors
Returns an error string when the cap is exceeded.
Sourcepub async fn is_empty(&self) -> bool
pub async fn is_empty(&self) -> bool
Check whether the subscription set is empty.
Used as a fast path in the diagnostics pump to skip URI construction when no client has subscribed yet.
Sourcepub async fn unsubscribe(&self, uri: &str) -> bool
pub async fn unsubscribe(&self, uri: &str) -> bool
Remove a URI from the subscription set.
Returns true if the URI was present and removed.
Trait Implementations§
Source§impl Debug for ResourceSubscriptions
impl Debug for ResourceSubscriptions
Auto Trait Implementations§
impl !Freeze for ResourceSubscriptions
impl !RefUnwindSafe for ResourceSubscriptions
impl !UnwindSafe for ResourceSubscriptions
impl Send for ResourceSubscriptions
impl Sync for ResourceSubscriptions
impl Unpin for ResourceSubscriptions
impl UnsafeUnpin for ResourceSubscriptions
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