[−][src]Trait misskey::StreamingClientExt
An extension trait for StreamingClient
that provides convenient high-level APIs.
Streams
The methods of StreamingClientExt
return (Future
that outputs) a
Stream
that receives items from the server asynchronously.
You can use methods from TryStreamExt
or StreamExt
to work with these streams.
Provided methods
pub fn subscribe_note(
&self,
note: impl EntityRef<Note>
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<NoteUpdateEvent, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
[src]
&self,
note: impl EntityRef<Note>
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<NoteUpdateEvent, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
Subscribes to the specified note and returns a stream to receive the events.
Examples
use futures::stream::TryStreamExt; use misskey::streaming::note::NoteUpdateEvent; let note = client.create_note("Hello!").await?; let mut note_stream = client.subscribe_note(¬e).await?; // Wait for the next event in the stream. while let Some(event) = note_stream.try_next().await? { match event { // Check if the event is 'reacted' NoteUpdateEvent::Reacted { reaction, user_id } => { println!("reacted by {}: {}", user_id, reaction); } // other events are just ignored here _ => {} } }
pub fn main_stream(
&self
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<MainStreamEvent, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
[src]
&self
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<MainStreamEvent, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
Returns a stream to receive the events from the main stream.
Note that currently it is not possible to have multiple connections to the main stream from
the same client. If you try to do so, the Future
returned by this method will not complete.
Examples
use futures::stream::TryStreamExt; use misskey::ClientExt; use misskey::streaming::channel::main::MainStreamEvent; let mut main_stream = client.main_stream().await?; // Wait for the next event in the main stream. while let Some(event) = main_stream.try_next().await? { match event { // Check if the event is 'followed' MainStreamEvent::Followed(user) => { // Follow back `user` if you haven't already. if !client.is_following(&user).await? { client.follow(&user).await?; } } // other events are just ignored here _ => {} } }
pub fn home_timeline(
&self
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Note, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
[src]
&self
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Note, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
Returns a stream to receive the notes in the home timeline.
Note that currently it is not possible to have multiple connections to the home timeline from
the same client. If you try to do so, the Future
returned by this method will not complete.
Examples
use futures::stream::TryStreamExt; use misskey::ClientExt; use misskey::model::note::Note; let mut home = client.home_timeline().await?; // Wait for the next note in the home timeline. while let Some(note) = home.try_next().await? { // if the note's text contains "Hello", react with "🙌". match note { Note { id, text: Some(text), .. } if text.contains("Hello") => { client.react(id, "🙌").await?; } _ => {} } }
pub fn local_timeline(
&self
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Note, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
[src]
&self
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Note, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
Returns a stream to receive the notes in the local timeline.
Note that currently it is not possible to have multiple connections to the local timeline from
the same client. If you try to do so, the Future
returned by this method will not complete.
pub fn social_timeline(
&self
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Note, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
[src]
&self
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Note, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
Returns a stream to receive the notes in the social timeline.
Note that currently it is not possible to have multiple connections to the social timeline from
the same client. If you try to do so, the Future
returned by this method will not complete.
pub fn global_timeline(
&self
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Note, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
[src]
&self
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Note, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
Returns a stream to receive the notes in the global timeline.
Note that currently it is not possible to have multiple connections to the global timeline from
the same client. If you try to do so, the Future
returned by this method will not complete.
pub fn hashtag_timeline(
&self,
query: impl Into<Query<String>>
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Note, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
[src]
&self,
query: impl Into<Query<String>>
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Note, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
Returns a stream to receive the notes with the given hashtags.
pub fn antenna_timeline(
&self,
antenna: impl EntityRef<Antenna>
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Note, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
[src]
&self,
antenna: impl EntityRef<Antenna>
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Note, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
Returns a stream to receive notes in the timeline of the specified antenna.
pub fn channel_timeline(
&self,
channel: impl EntityRef<Channel>
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Note, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
[src]
&self,
channel: impl EntityRef<Channel>
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Note, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
Returns a stream to receive notes in the timeline of the specified channel.
pub fn user_list_timeline(
&self,
list: impl EntityRef<UserList>
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Note, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
[src]
&self,
list: impl EntityRef<UserList>
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Note, Error<Self::Error>>> + Send, Global>>, Error<Self::Error>>> + Send, Global>>
Returns a stream to receive notes in the timeline of the specified user list.
Implementors
impl<C> StreamingClientExt for C where
C: Sync + StreamingClient,
[src]
C: Sync + StreamingClient,