pub struct SubscriptionHandle { /* private fields */ }Expand description
A handle to an active subscription that automatically unsubscribes when dropped.
SubscriptionHandle implements a RAII pattern for WebSocket subscriptions.
When the handle is dropped, it decrements the reference count for the stream
and triggers an UNSUBSCRIBE command if no more handles reference the stream.
§Example
ⓘ
let handle = subscription_manager.subscribe("btcusdt@ticker", ...).await?;
// ... use the subscription ...
drop(handle); // Automatically unsubscribes when droppedImplementations§
Source§impl SubscriptionHandle
impl SubscriptionHandle
Sourcepub fn new(
stream: String,
subscription_manager: Arc<SubscriptionManager>,
message_router: Option<Arc<MessageRouter>>,
) -> Self
pub fn new( stream: String, subscription_manager: Arc<SubscriptionManager>, message_router: Option<Arc<MessageRouter>>, ) -> Self
Creates a new subscription handle.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SubscriptionHandle
impl !RefUnwindSafe for SubscriptionHandle
impl Send for SubscriptionHandle
impl Sync for SubscriptionHandle
impl Unpin for SubscriptionHandle
impl UnsafeUnpin for SubscriptionHandle
impl !UnwindSafe for SubscriptionHandle
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