[][src]Trait misskey_util::StreamingClientExt

pub trait StreamingClientExt: StreamingClient + Sync {
    pub fn subscribe_note(
        &self,
        note: impl EntityRef<Note>
    ) -> BoxFuture<'_, Result<BoxStream<'_, Result<NoteUpdateEvent, Error<Self::Error>>>, Error<Self::Error>>> { ... }
pub fn main_stream(
        &self
    ) -> BoxFuture<'_, Result<BoxStream<'_, Result<MainStreamEvent, Error<Self::Error>>>, Error<Self::Error>>> { ... }
pub fn home_timeline(
        &self
    ) -> BoxFuture<'_, Result<BoxStream<'_, Result<Note, Error<Self::Error>>>, Error<Self::Error>>> { ... }
pub fn local_timeline(
        &self
    ) -> BoxFuture<'_, Result<BoxStream<'_, Result<Note, Error<Self::Error>>>, Error<Self::Error>>> { ... }
pub fn social_timeline(
        &self
    ) -> BoxFuture<'_, Result<BoxStream<'_, Result<Note, Error<Self::Error>>>, Error<Self::Error>>> { ... }
pub fn global_timeline(
        &self
    ) -> BoxFuture<'_, Result<BoxStream<'_, Result<Note, Error<Self::Error>>>, Error<Self::Error>>> { ... }
pub fn hashtag_timeline(
        &self,
        query: impl Into<Query<String>>
    ) -> BoxFuture<'_, Result<BoxStream<'_, Result<Note, Error<Self::Error>>>, Error<Self::Error>>> { ... }
pub fn antenna_timeline(
        &self,
        antenna: impl EntityRef<Antenna>
    ) -> BoxFuture<'_, Result<BoxStream<'_, Result<Note, Error<Self::Error>>>, Error<Self::Error>>> { ... }
pub fn channel_timeline(
        &self,
        channel: impl EntityRef<Channel>
    ) -> BoxFuture<'_, Result<BoxStream<'_, Result<Note, Error<Self::Error>>>, Error<Self::Error>>> { ... }
pub fn user_list_timeline(
        &self,
        list: impl EntityRef<UserList>
    ) -> BoxFuture<'_, Result<BoxStream<'_, Result<Note, Error<Self::Error>>>, Error<Self::Error>>> { ... } }

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>
) -> BoxFuture<'_, Result<BoxStream<'_, Result<NoteUpdateEvent, Error<Self::Error>>>, Error<Self::Error>>>
[src]

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(&note).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
) -> BoxFuture<'_, Result<BoxStream<'_, Result<MainStreamEvent, Error<Self::Error>>>, Error<Self::Error>>>
[src]

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
) -> BoxFuture<'_, Result<BoxStream<'_, Result<Note, Error<Self::Error>>>, Error<Self::Error>>>
[src]

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
) -> BoxFuture<'_, Result<BoxStream<'_, Result<Note, Error<Self::Error>>>, Error<Self::Error>>>
[src]

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
) -> BoxFuture<'_, Result<BoxStream<'_, Result<Note, Error<Self::Error>>>, Error<Self::Error>>>
[src]

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
) -> BoxFuture<'_, Result<BoxStream<'_, Result<Note, Error<Self::Error>>>, Error<Self::Error>>>
[src]

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>>
) -> BoxFuture<'_, Result<BoxStream<'_, Result<Note, Error<Self::Error>>>, Error<Self::Error>>>
[src]

Returns a stream to receive the notes with the given hashtags.

pub fn antenna_timeline(
    &self,
    antenna: impl EntityRef<Antenna>
) -> BoxFuture<'_, Result<BoxStream<'_, Result<Note, Error<Self::Error>>>, Error<Self::Error>>>
[src]

Returns a stream to receive notes in the timeline of the specified antenna.

pub fn channel_timeline(
    &self,
    channel: impl EntityRef<Channel>
) -> BoxFuture<'_, Result<BoxStream<'_, Result<Note, Error<Self::Error>>>, Error<Self::Error>>>
[src]

This is supported on crate feature 12-47-0 only.

Returns a stream to receive notes in the timeline of the specified channel.

pub fn user_list_timeline(
    &self,
    list: impl EntityRef<UserList>
) -> BoxFuture<'_, Result<BoxStream<'_, Result<Note, Error<Self::Error>>>, Error<Self::Error>>>
[src]

Returns a stream to receive notes in the timeline of the specified user list.

Loading content...

Implementors

impl<C: StreamingClient + Sync> StreamingClientExt for C[src]

Loading content...