Struct mastodon_async::mastodon::Mastodon
source · pub struct Mastodon(/* private fields */);
Expand description
Your mastodon application client, handles all requests to and from Mastodon.
Implementations§
source§impl Mastodon
impl Mastodon
sourcepub async fn favourites(&self) -> Result<Page<Status>>
pub async fn favourites(&self) -> Result<Page<Status>>
Equivalent to get /api/v1/favourites
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.favourites();
sourcepub async fn bookmarks(&self) -> Result<Page<Status>>
pub async fn bookmarks(&self) -> Result<Page<Status>>
Equivalent to get /api/v1/bookmarks
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.bookmarks();
sourcepub async fn blocks(&self) -> Result<Page<Account>>
pub async fn blocks(&self) -> Result<Page<Account>>
Equivalent to get /api/v1/blocks
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.blocks();
sourcepub async fn domain_blocks(&self) -> Result<Page<String>>
pub async fn domain_blocks(&self) -> Result<Page<String>>
Equivalent to get /api/v1/domain_blocks
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.domain_blocks();
sourcepub async fn follow_requests(&self) -> Result<Page<Account>>
pub async fn follow_requests(&self) -> Result<Page<Account>>
Equivalent to get /api/v1/follow_requests
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.follow_requests();
sourcepub async fn get_home_timeline(&self) -> Result<Page<Status>>
pub async fn get_home_timeline(&self) -> Result<Page<Status>>
Equivalent to get /api/v1/timelines/home
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.get_home_timeline();
sourcepub async fn get_emojis(&self) -> Result<Page<Emoji>>
pub async fn get_emojis(&self) -> Result<Page<Emoji>>
Equivalent to get /api/v1/custom_emojis
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.get_emojis();
sourcepub async fn mutes(&self) -> Result<Page<Account>>
pub async fn mutes(&self) -> Result<Page<Account>>
Equivalent to get /api/v1/mutes
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.mutes();
sourcepub async fn notifications(&self) -> Result<Page<Notification>>
pub async fn notifications(&self) -> Result<Page<Notification>>
Equivalent to get /api/v1/notifications
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.notifications();
sourcepub async fn reports(&self) -> Result<Page<Report>>
pub async fn reports(&self) -> Result<Page<Report>>
Equivalent to get /api/v1/reports
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.reports();
sourcepub async fn search_accounts<'a>(
&self,
q: &'a str,
limit: Option<u64>,
following: bool
) -> Result<Page<Account>>
pub async fn search_accounts<'a>( &self, q: &'a str, limit: Option<u64>, following: bool ) -> Result<Page<Account>>
sourcepub async fn get_endorsements(&self) -> Result<Page<Account>>
pub async fn get_endorsements(&self) -> Result<Page<Account>>
Equivalent to get /api/v1/endorsements
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.get_endorsements();
sourcepub async fn followers(&self, id: impl AsRef<str>) -> Result<Page<Account>>
pub async fn followers(&self, id: impl AsRef<str>) -> Result<Page<Account>>
Equivalent to get /api/v1/accounts/{}/followers
§Errors
If access_token
is not set.
let data = Data::default();let client = Mastodon::from(data);
client.followers("some-id");
sourcepub async fn following(&self, id: impl AsRef<str>) -> Result<Page<Account>>
pub async fn following(&self, id: impl AsRef<str>) -> Result<Page<Account>>
Equivalent to get /api/v1/accounts/{}/following
§Errors
If access_token
is not set.
let data = Data::default();let client = Mastodon::from(data);
client.following("some-id");
sourcepub async fn reblogged_by(&self, id: impl AsRef<str>) -> Result<Page<Account>>
pub async fn reblogged_by(&self, id: impl AsRef<str>) -> Result<Page<Account>>
Equivalent to get /api/v1/statuses/{}/reblogged_by
§Errors
If access_token
is not set.
let data = Data::default();let client = Mastodon::from(data);
client.reblogged_by("some-id");
sourcepub async fn favourited_by(&self, id: impl AsRef<str>) -> Result<Page<Account>>
pub async fn favourited_by(&self, id: impl AsRef<str>) -> Result<Page<Account>>
Equivalent to get /api/v1/statuses/{}/favourited_by
§Errors
If access_token
is not set.
let data = Data::default();let client = Mastodon::from(data);
client.favourited_by("some-id");
sourcepub async fn unblock_domain(&self, domain: String) -> Result<Empty>
pub async fn unblock_domain(&self, domain: String) -> Result<Empty>
sourcepub async fn instance(&self) -> Result<Instance>
pub async fn instance(&self) -> Result<Instance>
Equivalent to get /api/v1/instance
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.instance();
sourcepub async fn verify_credentials(&self) -> Result<Account>
pub async fn verify_credentials(&self) -> Result<Account>
Equivalent to get /api/v1/accounts/verify_credentials
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.verify_credentials();
sourcepub async fn report(
&self,
account_id: &str,
status_ids: Vec<&str>,
comment: String
) -> Result<Report>
pub async fn report( &self, account_id: &str, status_ids: Vec<&str>, comment: String ) -> Result<Report>
sourcepub async fn block_domain(&self, domain: String) -> Result<Empty>
pub async fn block_domain(&self, domain: String) -> Result<Empty>
sourcepub async fn reject_follow_request(&self, id: &str) -> Result<Empty>
pub async fn reject_follow_request(&self, id: &str) -> Result<Empty>
sourcepub async fn clear_notifications(&self) -> Result<Empty>
pub async fn clear_notifications(&self) -> Result<Empty>
Equivalent to post /api/v1/notifications/clear
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.clear_notifications();
sourcepub async fn get_push_subscription(&self) -> Result<Subscription>
pub async fn get_push_subscription(&self) -> Result<Subscription>
Equivalent to get /api/v1/push/subscription
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.get_push_subscription();
sourcepub async fn delete_push_subscription(&self) -> Result<Empty>
pub async fn delete_push_subscription(&self) -> Result<Empty>
Equivalent to delete /api/v1/push/subscription
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.delete_push_subscription();
sourcepub async fn get_filters(&self) -> Result<Vec<Filter>>
pub async fn get_filters(&self) -> Result<Vec<Filter>>
Equivalent to get /api/v1/filters
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.get_filters();
sourcepub async fn get_follow_suggestions(&self) -> Result<Vec<Account>>
pub async fn get_follow_suggestions(&self) -> Result<Vec<Account>>
Equivalent to get /api/v1/suggestions
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.get_follow_suggestions();
sourcepub async fn media(
&self,
file: impl AsRef<Path>,
description: Option<String>
) -> Result<Attachment>
pub async fn media( &self, file: impl AsRef<Path>, description: Option<String> ) -> Result<Attachment>
sourcepub async fn media_with_thumbnail(
&self,
file: impl AsRef<Path>,
thumbnail: impl AsRef<Path>,
description: Option<String>
) -> Result<Attachment>
pub async fn media_with_thumbnail( &self, file: impl AsRef<Path>, thumbnail: impl AsRef<Path>, description: Option<String> ) -> Result<Attachment>
sourcepub async fn get_account(&self, id: &AccountId) -> Result<Account>
pub async fn get_account(&self, id: &AccountId) -> Result<Account>
Equivalent to get /api/v1/accounts/{}
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.get_account("42");
# Ok(())
# }
sourcepub async fn follow(&self, id: &AccountId) -> Result<Relationship>
pub async fn follow(&self, id: &AccountId) -> Result<Relationship>
Equivalent to post /api/v1/accounts/{}/follow
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.follow("42");
# Ok(())
# }
sourcepub async fn unfollow(&self, id: &AccountId) -> Result<Relationship>
pub async fn unfollow(&self, id: &AccountId) -> Result<Relationship>
Equivalent to post /api/v1/accounts/{}/unfollow
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.unfollow("42");
# Ok(())
# }
sourcepub async fn block(&self, id: &AccountId) -> Result<Relationship>
pub async fn block(&self, id: &AccountId) -> Result<Relationship>
Equivalent to post /api/v1/accounts/{}/block
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.block("42");
# Ok(())
# }
sourcepub async fn unblock(&self, id: &AccountId) -> Result<Relationship>
pub async fn unblock(&self, id: &AccountId) -> Result<Relationship>
Equivalent to post /api/v1/accounts/{}/unblock
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.unblock("42");
# Ok(())
# }
sourcepub async fn mute(&self, id: &AccountId) -> Result<Relationship>
pub async fn mute(&self, id: &AccountId) -> Result<Relationship>
Equivalent to get /api/v1/accounts/{}/mute
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.mute("42");
# Ok(())
# }
sourcepub async fn unmute(&self, id: &AccountId) -> Result<Relationship>
pub async fn unmute(&self, id: &AccountId) -> Result<Relationship>
Equivalent to get /api/v1/accounts/{}/unmute
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.unmute("42");
# Ok(())
# }
sourcepub async fn get_notification(
&self,
id: &NotificationId
) -> Result<Notification>
pub async fn get_notification( &self, id: &NotificationId ) -> Result<Notification>
Equivalent to get /api/v1/notifications/{}
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.get_notification("42");
# Ok(())
# }
sourcepub async fn dismiss_notification(&self, id: &NotificationId) -> Result<Empty>
pub async fn dismiss_notification(&self, id: &NotificationId) -> Result<Empty>
Equivalent to post /api/v1/notifications/{}/dismiss
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.dismiss_notification("42");
# Ok(())
# }
sourcepub async fn get_status(&self, id: &StatusId) -> Result<Status>
pub async fn get_status(&self, id: &StatusId) -> Result<Status>
Equivalent to get /api/v1/statuses/{}
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.get_status("42");
# Ok(())
# }
sourcepub async fn get_context(&self, id: &StatusId) -> Result<Context>
pub async fn get_context(&self, id: &StatusId) -> Result<Context>
Equivalent to get /api/v1/statuses/{}/context
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.get_context("42");
# Ok(())
# }
sourcepub async fn get_card(&self, id: &StatusId) -> Result<Card>
pub async fn get_card(&self, id: &StatusId) -> Result<Card>
Equivalent to get /api/v1/statuses/{}/card
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.get_card("42");
# Ok(())
# }
sourcepub async fn reblog(&self, id: &StatusId) -> Result<Status>
pub async fn reblog(&self, id: &StatusId) -> Result<Status>
Equivalent to post /api/v1/statuses/{}/reblog
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.reblog("42");
# Ok(())
# }
sourcepub async fn unreblog(&self, id: &StatusId) -> Result<Status>
pub async fn unreblog(&self, id: &StatusId) -> Result<Status>
Equivalent to post /api/v1/statuses/{}/unreblog
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.unreblog("42");
# Ok(())
# }
sourcepub async fn favourite(&self, id: &StatusId) -> Result<Status>
pub async fn favourite(&self, id: &StatusId) -> Result<Status>
Equivalent to post /api/v1/statuses/{}/favourite
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.favourite("42");
# Ok(())
# }
sourcepub async fn unfavourite(&self, id: &StatusId) -> Result<Status>
pub async fn unfavourite(&self, id: &StatusId) -> Result<Status>
Equivalent to post /api/v1/statuses/{}/unfavourite
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.unfavourite("42");
# Ok(())
# }
sourcepub async fn delete_status(&self, id: &StatusId) -> Result<Empty>
pub async fn delete_status(&self, id: &StatusId) -> Result<Empty>
Equivalent to delete /api/v1/statuses/{}
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.delete_status("42");
# Ok(())
# }
sourcepub async fn get_filter(&self, id: &FilterId) -> Result<Filter>
pub async fn get_filter(&self, id: &FilterId) -> Result<Filter>
Equivalent to get /api/v1/filters/{}
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.get_filter("42");
# Ok(())
# }
sourcepub async fn delete_filter(&self, id: &FilterId) -> Result<Empty>
pub async fn delete_filter(&self, id: &FilterId) -> Result<Empty>
Equivalent to delete /api/v1/filters/{}
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.delete_filter("42");
# Ok(())
# }
sourcepub async fn delete_from_suggestions(&self, id: &AccountId) -> Result<Empty>
pub async fn delete_from_suggestions(&self, id: &AccountId) -> Result<Empty>
Equivalent to delete /api/v1/suggestions/{}
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.delete_from_suggestions("42");
# Ok(())
# }
sourcepub async fn endorse_user(&self, id: &AccountId) -> Result<Relationship>
pub async fn endorse_user(&self, id: &AccountId) -> Result<Relationship>
Equivalent to post /api/v1/accounts/{}/pin
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.endorse_user("42");
# Ok(())
# }
sourcepub async fn unendorse_user(&self, id: &AccountId) -> Result<Relationship>
pub async fn unendorse_user(&self, id: &AccountId) -> Result<Relationship>
Equivalent to post /api/v1/accounts/{}/unpin
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.unendorse_user("42");
# Ok(())
# }
sourcepub async fn attachment(&self, id: &AttachmentId) -> Result<Attachment>
pub async fn attachment(&self, id: &AttachmentId) -> Result<Attachment>
Equivalent to get /api/v1/media/{}
§Errors
If access_token
is not set.
let data = Data::default();
let client = Mastodon::from(data);
client.attachment("42");
# Ok(())
# }
sourcepub async fn stream_user(
&self
) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
pub async fn stream_user( &self ) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
returns events that are relevant to the authorized user, i.e. home timeline & notifications
Example:
use mastodon_async::prelude::*; use mastodon_async::entities::event::Event; use futures_util::{pin_mut, StreamExt, TryStreamExt};
tokio_test::block_on(async { let data = Data::default(); let client = Mastodon::from(data); let stream = client.stream_user().await.unwrap(); stream.try_for_each(|event| async move { match event { Event::Update(ref status) => { /* .. / }, Event::Notification(ref notification) => { / .. / }, Event::Delete(ref id) => { / .. / }, Event::FiltersChanged => { / .. */ }, } Ok(()) }).await.unwrap(); });
sourcepub async fn stream_public(
&self
) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
pub async fn stream_public( &self ) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
All public posts known to the server. Analogous to the federated timeline.
Example:
use mastodon_async::prelude::*; use mastodon_async::entities::event::Event; use futures_util::{pin_mut, StreamExt, TryStreamExt};
tokio_test::block_on(async { let data = Data::default(); let client = Mastodon::from(data); let stream = client.stream_public().await.unwrap(); stream.try_for_each(|event| async move { match event { Event::Update(ref status) => { /* .. / }, Event::Notification(ref notification) => { / .. / }, Event::Delete(ref id) => { / .. / }, Event::FiltersChanged => { / .. */ }, } Ok(()) }).await.unwrap(); });
sourcepub async fn stream_public_media(
&self
) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
pub async fn stream_public_media( &self ) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
All public posts known to the server, filtered for media attachments. Analogous to the federated timeline with ‘only media’ enabled.
Example:
use mastodon_async::prelude::*; use mastodon_async::entities::event::Event; use futures_util::{pin_mut, StreamExt, TryStreamExt};
tokio_test::block_on(async { let data = Data::default(); let client = Mastodon::from(data); let stream = client.stream_public_media().await.unwrap(); stream.try_for_each(|event| async move { match event { Event::Update(ref status) => { /* .. / }, Event::Notification(ref notification) => { / .. / }, Event::Delete(ref id) => { / .. / }, Event::FiltersChanged => { / .. */ }, } Ok(()) }).await.unwrap(); });
sourcepub async fn stream_local(
&self,
only_media: bool
) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
pub async fn stream_local( &self, only_media: bool ) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
All public posts originating from this server.
Example:
use mastodon_async::prelude::*; use mastodon_async::entities::event::Event; use futures_util::{pin_mut, StreamExt, TryStreamExt};
tokio_test::block_on(async { let data = Data::default(); let client = Mastodon::from(data); let stream = client.stream_local(false).await.unwrap(); stream.try_for_each(|event| async move { match event { Event::Update(ref status) => { /* .. / }, Event::Notification(ref notification) => { / .. / }, Event::Delete(ref id) => { / .. / }, Event::FiltersChanged => { / .. */ }, } Ok(()) }).await.unwrap(); });
sourcepub async fn stream_remote(
&self,
only_media: bool
) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
pub async fn stream_remote( &self, only_media: bool ) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
All public posts originating from other servers.
Example:
use mastodon_async::prelude::*; use mastodon_async::entities::event::Event; use futures_util::{pin_mut, StreamExt, TryStreamExt};
tokio_test::block_on(async { let data = Data::default(); let client = Mastodon::from(data); let stream = client.stream_remote(false).await.unwrap(); stream.try_for_each(|event| async move { match event { Event::Update(ref status) => { /* .. / }, Event::Notification(ref notification) => { / .. / }, Event::Delete(ref id) => { / .. / }, Event::FiltersChanged => { / .. */ }, } Ok(()) }).await.unwrap(); });
sourcepub async fn stream_hashtag(
&self,
tag: impl AsRef<str>
) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
pub async fn stream_hashtag( &self, tag: impl AsRef<str> ) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
All public posts using a certain hashtag.
Example:
use mastodon_async::prelude::*; use mastodon_async::entities::event::Event; use futures_util::{pin_mut, StreamExt, TryStreamExt};
tokio_test::block_on(async { let data = Data::default(); let client = Mastodon::from(data); let stream = client.stream_hashtag(#bots).await.unwrap(); stream.try_for_each(|event| async move { match event { Event::Update(ref status) => { /* .. / }, Event::Notification(ref notification) => { / .. / }, Event::Delete(ref id) => { / .. / }, Event::FiltersChanged => { / .. */ }, } Ok(()) }).await.unwrap(); });
sourcepub async fn stream_local_hashtag(
&self,
tag: impl AsRef<str>
) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
pub async fn stream_local_hashtag( &self, tag: impl AsRef<str> ) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
All public posts using a certain hashtag, originating from this server.
Example:
use mastodon_async::prelude::*; use mastodon_async::entities::event::Event; use futures_util::{pin_mut, StreamExt, TryStreamExt};
tokio_test::block_on(async { let data = Data::default(); let client = Mastodon::from(data); let stream = client.stream_local_hashtag(#bots).await.unwrap(); stream.try_for_each(|event| async move { match event { Event::Update(ref status) => { /* .. / }, Event::Notification(ref notification) => { / .. / }, Event::Delete(ref id) => { / .. / }, Event::FiltersChanged => { / .. */ }, } Ok(()) }).await.unwrap(); });
sourcepub async fn stream_notifications(
&self
) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
pub async fn stream_notifications( &self ) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
Notifications for the current user.
Example:
use mastodon_async::prelude::*; use mastodon_async::entities::event::Event; use futures_util::{pin_mut, StreamExt, TryStreamExt};
tokio_test::block_on(async { let data = Data::default(); let client = Mastodon::from(data); let stream = client.stream_notifications().await.unwrap(); stream.try_for_each(|event| async move { match event { Event::Update(ref status) => { /* .. / }, Event::Notification(ref notification) => { / .. / }, Event::Delete(ref id) => { / .. / }, Event::FiltersChanged => { / .. */ }, } Ok(()) }).await.unwrap(); });
sourcepub async fn stream_list(
&self,
list: impl AsRef<str>
) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
pub async fn stream_list( &self, list: impl AsRef<str> ) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
Updates to a specific list.
Example:
use mastodon_async::prelude::*; use mastodon_async::entities::event::Event; use futures_util::{pin_mut, StreamExt, TryStreamExt};
tokio_test::block_on(async { let data = Data::default(); let client = Mastodon::from(data); let stream = client.stream_list(12345).await.unwrap(); stream.try_for_each(|event| async move { match event { Event::Update(ref status) => { /* .. / }, Event::Notification(ref notification) => { / .. / }, Event::Delete(ref id) => { / .. / }, Event::FiltersChanged => { / .. */ }, } Ok(()) }).await.unwrap(); });
sourcepub async fn stream_direct(
&self
) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
pub async fn stream_direct( &self ) -> Result<impl TryStream<Ok = (Event, Mastodon), Error = Error> + '_>
Updates to direct conversations.
Example:
use mastodon_async::prelude::*; use mastodon_async::entities::event::Event; use futures_util::{pin_mut, StreamExt, TryStreamExt};
tokio_test::block_on(async { let data = Data::default(); let client = Mastodon::from(data); let stream = client.stream_direct().await.unwrap(); stream.try_for_each(|event| async move { match event { Event::Update(ref status) => { /* .. / }, Event::Notification(ref notification) => { / .. / }, Event::Delete(ref id) => { / .. / }, Event::FiltersChanged => { / .. */ }, } Ok(()) }).await.unwrap(); });
sourcepub async fn add_filter(&self, request: &mut AddFilterRequest) -> Result<Filter>
pub async fn add_filter(&self, request: &mut AddFilterRequest) -> Result<Filter>
POST /api/v1/filters
sourcepub async fn update_filter(
&self,
id: &str,
request: &mut AddFilterRequest
) -> Result<Filter>
pub async fn update_filter( &self, id: &str, request: &mut AddFilterRequest ) -> Result<Filter>
PUT /api/v1/filters/:id
sourcepub async fn update_credentials(
&self,
builder: &mut UpdateCredsRequest
) -> Result<Account>
pub async fn update_credentials( &self, builder: &mut UpdateCredsRequest ) -> Result<Account>
Update the user credentials
sourcepub async fn new_status(&self, status: NewStatus) -> Result<Status>
pub async fn new_status(&self, status: NewStatus) -> Result<Status>
Post a new status to the account.
sourcepub async fn get_tagged_timeline(
&self,
hashtag: String,
local: bool
) -> Result<Vec<Status>>
pub async fn get_tagged_timeline( &self, hashtag: String, local: bool ) -> Result<Vec<Status>>
Get timeline filtered by a hashtag(eg. #coffee
) either locally or
federated.
sourcepub async fn statuses<'a, 'b: 'a>(
&'b self,
id: &'b AccountId,
request: StatusesRequest<'a>
) -> Result<Page<Status>>
pub async fn statuses<'a, 'b: 'a>( &'b self, id: &'b AccountId, request: StatusesRequest<'a> ) -> Result<Page<Status>>
Get statuses of a single account by id. Optionally only with pictures and or excluding replies.
// Example
use mastodon_async::prelude::*;
tokio_test::block_on(async {
let data = Data::default();
let client = Mastodon::from(data);
let statuses = client.statuses(&AccountId::new("user-id"), Default::default()).await.unwrap();
});
use mastodon_async::prelude::*;
tokio_test::block_on(async {
let data = Data::default();
let client = Mastodon::from(data);
let mut request = StatusesRequest::new();
request.only_media();
let statuses = client.statuses(&AccountId::new("user-id"), request).await.unwrap();
});
sourcepub async fn relationships(
&self,
ids: &[&AccountId]
) -> Result<Page<Relationship>>
pub async fn relationships( &self, ids: &[&AccountId] ) -> Result<Page<Relationship>>
Returns the client account’s relationship to a list of other accounts. Such as whether they follow them or vice versa.
sourcepub async fn add_push_subscription(
&self,
request: &AddPushRequest
) -> Result<Subscription>
pub async fn add_push_subscription( &self, request: &AddPushRequest ) -> Result<Subscription>
Add a push notifications subscription
sourcepub async fn update_push_data(
&self,
request: &UpdatePushRequest
) -> Result<Subscription>
pub async fn update_push_data( &self, request: &UpdatePushRequest ) -> Result<Subscription>
Update the data
portion of the push subscription associated with this
access token
sourcepub async fn follows_me(&self) -> Result<Page<Account>>
pub async fn follows_me(&self) -> Result<Page<Account>>
Get all accounts that follow the authenticated user
sourcepub async fn followed_by_me(&self) -> Result<Page<Account>>
pub async fn followed_by_me(&self) -> Result<Page<Account>>
Get all accounts that the authenticated user follows
sourcepub async fn wait_for_processing(
&self,
attachment: Attachment,
polling_time: PollingTime
) -> Result<ProcessedAttachment>
pub async fn wait_for_processing( &self, attachment: Attachment, polling_time: PollingTime ) -> Result<ProcessedAttachment>
Wait for the media to be done processing and return it with the URL.
Default::default()
may be passed as the polling time to select a
polling time of 500ms.
§Example
use mastodon_async::prelude::*;
let mastodon = Mastodon::from(Data::default());
tokio_test::block_on(async {
let attachment = mastodon.media("/path/to/some/file.jpg", None).await.expect("upload");
let attachment = mastodon.wait_for_processing(attachment, Default::default()).await.expect("processing");
println!("{}", attachment.url);
});
For a different polling time, use .into()
on a std::time::Duration
.
use mastodon_async::prelude::*;
use std::time::Duration;
let mastodon = Mastodon::from(Data::default());
tokio_test::block_on(async {
let attachment = mastodon.media("/path/to/some/file.jpg", None).await.expect("upload");
let attachment = mastodon.wait_for_processing(
attachment,
Duration::from_secs(1).into(),
).await.expect("processing");
println!("{}", attachment.url);
});