pub struct TopicCollection { /* private fields */ }Expand description
Represents a collection of topics.
This is used to subscribe to multiple topics at once.
§Examples
use nt_client::Client;
let client = Client::new(Default::default());
client.connect_setup(setup).await.unwrap();
fn setup(client: &Client) {
let topics = client.topics(vec![
"/topic".to_owned(),
"/nested/topic".to_owned(),
"/deeply/nested/topic".to_owned(),
]);
tokio::spawn(async move {
let subscriber = topics.subscribe(Default::default()).await;
// do something with subscriber...
});
}Implementations§
Source§impl TopicCollection
impl TopicCollection
Sourcepub fn names_mut(&mut self) -> &mut Vec<String>
pub fn names_mut(&mut self) -> &mut Vec<String>
Returns a mutable slice of topic names this collection contains.
Sourcepub async fn subscribe(
&self,
options: SubscriptionOptions,
) -> Result<Subscriber, ConnectionClosedError>
pub async fn subscribe( &self, options: SubscriptionOptions, ) -> Result<Subscriber, ConnectionClosedError>
Subscribes to this collection of topics.
This method does not require the Client websocket connection to be made.
Trait Implementations§
Source§impl Clone for TopicCollection
impl Clone for TopicCollection
Source§fn clone(&self) -> TopicCollection
fn clone(&self) -> TopicCollection
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TopicCollection
impl Debug for TopicCollection
Source§impl IntoIterator for TopicCollection
impl IntoIterator for TopicCollection
Source§impl PartialEq for TopicCollection
impl PartialEq for TopicCollection
impl Eq for TopicCollection
Auto Trait Implementations§
impl Freeze for TopicCollection
impl !RefUnwindSafe for TopicCollection
impl Send for TopicCollection
impl Sync for TopicCollection
impl Unpin for TopicCollection
impl UnsafeUnpin for TopicCollection
impl !UnwindSafe for TopicCollection
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