use core::fmt;
use std::str::FromStr;
use crate::error::{Error, Kind};
use crate::oauth::{AppData, TokenData};
use crate::response::Response;
use crate::{entities, Streaming};
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use serde::Serialize;
use tokio::{fs::File, io::AsyncRead};
#[async_trait]
pub trait Megalodon {
async fn register_app(
&self,
client_name: String,
options: &AppInputOptions,
) -> Result<AppData, Error>;
async fn create_app(
&self,
client_name: String,
options: &AppInputOptions,
) -> Result<AppData, Error>;
async fn fetch_access_token(
&self,
client_id: String,
client_secret: String,
code: String,
redirect_uri: String,
) -> Result<TokenData, Error>;
async fn refresh_access_token(
&self,
client_id: String,
client_secret: String,
refresh_token: String,
) -> Result<TokenData, Error>;
async fn revoke_access_token(
&self,
client_id: String,
client_secret: String,
access_token: String,
) -> Result<Response<()>, Error>;
async fn verify_app_credentials(&self) -> Result<Response<entities::Application>, Error>;
async fn register_account(
&self,
username: String,
email: String,
password: String,
agreement: String,
locale: String,
reason: Option<String>,
) -> Result<Response<entities::Token>, Error>;
async fn verify_account_credentials(&self) -> Result<Response<entities::Account>, Error>;
async fn update_credentials(
&self,
options: Option<&UpdateCredentialsInputOptions>,
) -> Result<Response<entities::Account>, Error>;
async fn get_account(&self, id: String) -> Result<Response<entities::Account>, Error>;
async fn get_account_statuses(
&self,
id: String,
options: Option<&GetAccountStatusesInputOptions>,
) -> Result<Response<Vec<entities::Status>>, Error>;
async fn get_account_favourites(
&self,
id: String,
options: Option<&GetAccountFavouritesInputOptions>,
) -> Result<Response<Vec<entities::Status>>, Error>;
async fn subscribe_account(
&self,
id: String,
) -> Result<Response<entities::Relationship>, Error>;
async fn unsubscribe_account(
&self,
id: String,
) -> Result<Response<entities::Relationship>, Error>;
async fn get_account_followers(
&self,
id: String,
options: Option<&AccountFollowersInputOptions>,
) -> Result<Response<Vec<entities::Account>>, Error>;
async fn get_account_following(
&self,
id: String,
options: Option<&AccountFollowersInputOptions>,
) -> Result<Response<Vec<entities::Account>>, Error>;
async fn get_account_lists(&self, id: String) -> Result<Response<Vec<entities::List>>, Error>;
async fn get_identity_proofs(
&self,
id: String,
) -> Result<Response<Vec<entities::IdentityProof>>, Error>;
async fn follow_account(
&self,
id: String,
options: Option<&FollowAccountInputOptions>,
) -> Result<Response<entities::Relationship>, Error>;
async fn unfollow_account(&self, id: String)
-> Result<Response<entities::Relationship>, Error>;
async fn block_account(&self, id: String) -> Result<Response<entities::Relationship>, Error>;
async fn unblock_account(&self, id: String) -> Result<Response<entities::Relationship>, Error>;
async fn mute_account(
&self,
id: String,
notifications: bool,
) -> Result<Response<entities::Relationship>, Error>;
async fn unmute_account(&self, id: String) -> Result<Response<entities::Relationship>, Error>;
async fn pin_account(&self, id: String) -> Result<Response<entities::Relationship>, Error>;
async fn unpin_account(&self, id: String) -> Result<Response<entities::Relationship>, Error>;
async fn set_account_note(
&self,
id: String,
note: Option<String>,
) -> Result<Response<entities::Relationship>, Error>;
async fn get_relationships(
&self,
ids: Vec<String>,
) -> Result<Response<Vec<entities::Relationship>>, Error>;
async fn search_account(
&self,
q: String,
options: Option<&SearchAccountInputOptions>,
) -> Result<Response<Vec<entities::Account>>, Error>;
async fn lookup_account(&self, acct: String) -> Result<Response<entities::Account>, Error>;
async fn get_bookmarks(
&self,
options: Option<&GetBookmarksInputOptions>,
) -> Result<Response<Vec<entities::Status>>, Error>;
async fn get_favourites(
&self,
options: Option<&GetFavouritesInputOptions>,
) -> Result<Response<Vec<entities::Status>>, Error>;
async fn get_mutes(
&self,
options: Option<&GetMutesInputOptions>,
) -> Result<Response<Vec<entities::Account>>, Error>;
async fn get_blocks(
&self,
options: Option<&GetBlocksInputOptions>,
) -> Result<Response<Vec<entities::Account>>, Error>;
async fn get_domain_blocks(
&self,
options: Option<&GetDomainBlocksInputOptions>,
) -> Result<Response<Vec<String>>, Error>;
async fn block_domain(&self, domain: String) -> Result<Response<()>, Error>;
async fn unblock_domain(&self, domain: String) -> Result<Response<()>, Error>;
async fn get_filters(&self) -> Result<Response<Vec<entities::Filter>>, Error>;
async fn get_filter(&self, id: String) -> Result<Response<entities::Filter>, Error>;
async fn create_filter(
&self,
phrase: String,
context: Vec<entities::filter::FilterContext>,
options: Option<&FilterInputOptions>,
) -> Result<Response<entities::Filter>, Error>;
async fn update_filter(
&self,
id: String,
phrase: String,
context: Vec<entities::filter::FilterContext>,
options: Option<&FilterInputOptions>,
) -> Result<Response<entities::Filter>, Error>;
async fn delete_filter(&self, id: String) -> Result<Response<()>, Error>;
async fn report(
&self,
account_id: String,
options: Option<&ReportInputOptions>,
) -> Result<Response<entities::Report>, Error>;
async fn get_follow_requests(
&self,
limit: Option<u32>,
) -> Result<Response<Vec<FollowRequestOutput>>, Error>;
async fn accept_follow_request(
&self,
id: String,
) -> Result<Response<entities::Relationship>, Error>;
async fn reject_follow_request(
&self,
id: String,
) -> Result<Response<entities::Relationship>, Error>;
async fn get_endorsements(
&self,
options: Option<&GetEndorsementsInputOptions>,
) -> Result<Response<Vec<entities::Account>>, Error>;
async fn get_featured_tags(&self) -> Result<Response<Vec<entities::FeaturedTag>>, Error>;
async fn create_featured_tag(
&self,
name: String,
) -> Result<Response<entities::FeaturedTag>, Error>;
async fn delete_featured_tag(&self, id: String) -> Result<Response<()>, Error>;
async fn get_suggested_tags(&self) -> Result<Response<Vec<entities::Tag>>, Error>;
async fn get_preferences(&self) -> Result<Response<entities::Preferences>, Error>;
async fn get_followed_tags(&self) -> Result<Response<Vec<entities::Tag>>, Error>;
async fn get_suggestions(
&self,
limit: Option<u32>,
) -> Result<Response<Vec<entities::Account>>, Error>;
async fn get_tag(&self, id: String) -> Result<Response<entities::Tag>, Error>;
async fn follow_tag(&self, id: String) -> Result<Response<entities::Tag>, Error>;
async fn unfollow_tag(&self, id: String) -> Result<Response<entities::Tag>, Error>;
async fn post_status(
&self,
status: String,
options: Option<&PostStatusInputOptions>,
) -> Result<Response<PostStatusOutput>, Error>;
async fn get_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
async fn get_status_source(
&self,
id: String,
) -> Result<Response<entities::StatusSource>, Error>;
async fn edit_status(
&self,
id: String,
options: &EditStatusInputOptions,
) -> Result<Response<entities::Status>, Error>;
async fn delete_status(&self, id: String) -> Result<Response<()>, Error>;
async fn get_status_context(
&self,
id: String,
options: Option<&GetStatusContextInputOptions>,
) -> Result<Response<entities::Context>, Error>;
async fn get_status_reblogged_by(
&self,
id: String,
) -> Result<Response<Vec<entities::Account>>, Error>;
async fn get_status_favourited_by(
&self,
id: String,
) -> Result<Response<Vec<entities::Account>>, Error>;
async fn favourite_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
async fn unfavourite_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
async fn reblog_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
async fn unreblog_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
async fn bookmark_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
async fn unbookmark_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
async fn mute_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
async fn unmute_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
async fn pin_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
async fn unpin_status(&self, id: String) -> Result<Response<entities::Status>, Error>;
async fn upload_media(
&self,
file_path: String,
options: Option<&UploadMediaInputOptions>,
) -> Result<Response<entities::UploadMedia>, Error> {
let file = File::open(file_path.clone()).await?;
self.upload_media_reader(Box::new(file), options, Some(file_path)).await
}
async fn upload_media_reader(
&self,
reader: Box<dyn AsyncRead + Sync + Send + Unpin>,
options: Option<&UploadMediaInputOptions>,
file_name: Option<String>,
) -> Result<Response<entities::UploadMedia>, Error>;
async fn get_media(&self, id: String) -> Result<Response<entities::Attachment>, Error>;
async fn update_media(
&self,
id: String,
options: Option<&UpdateMediaInputOptions>,
) -> Result<Response<entities::Attachment>, Error>;
async fn get_poll(&self, id: String) -> Result<Response<entities::Poll>, Error>;
async fn vote_poll(
&self,
id: String,
choices: Vec<u32>,
status_id: Option<String>,
) -> Result<Response<entities::Poll>, Error>;
async fn get_scheduled_statuses(
&self,
options: Option<&GetScheduledStatusesInputOptions>,
) -> Result<Response<Vec<entities::ScheduledStatus>>, Error>;
async fn get_scheduled_status(
&self,
id: String,
) -> Result<Response<entities::ScheduledStatus>, Error>;
async fn schedule_status(
&self,
id: String,
scheduled_at: Option<DateTime<Utc>>,
) -> Result<Response<entities::ScheduledStatus>, Error>;
async fn cancel_scheduled_status(&self, id: String) -> Result<Response<()>, Error>;
async fn get_public_timeline(
&self,
options: Option<&GetPublicTimelineInputOptions>,
) -> Result<Response<Vec<entities::Status>>, Error>;
async fn get_local_timeline(
&self,
options: Option<&GetLocalTimelineInputOptions>,
) -> Result<Response<Vec<entities::Status>>, Error>;
async fn get_tag_timeline(
&self,
hashtag: String,
options: Option<&GetTagTimelineInputOptions>,
) -> Result<Response<Vec<entities::Status>>, Error>;
async fn get_home_timeline(
&self,
options: Option<&GetHomeTimelineInputOptions>,
) -> Result<Response<Vec<entities::Status>>, Error>;
async fn get_list_timeline(
&self,
list_id: String,
options: Option<&GetListTimelineInputOptions>,
) -> Result<Response<Vec<entities::Status>>, Error>;
async fn get_conversation_timeline(
&self,
options: Option<&GetConversationTimelineInputOptions>,
) -> Result<Response<Vec<entities::Conversation>>, Error>;
async fn delete_conversation(&self, id: String) -> Result<Response<()>, Error>;
async fn read_conversation(
&self,
id: String,
) -> Result<Response<entities::Conversation>, Error>;
async fn get_lists(&self) -> Result<Response<Vec<entities::List>>, Error>;
async fn get_list(&self, id: String) -> Result<Response<entities::List>, Error>;
async fn create_list(&self, title: String) -> Result<Response<entities::List>, Error>;
async fn update_list(
&self,
id: String,
title: String,
) -> Result<Response<entities::List>, Error>;
async fn delete_list(&self, id: String) -> Result<Response<()>, Error>;
async fn get_accounts_in_list(
&self,
id: String,
options: Option<&GetAccountsInListInputOptions>,
) -> Result<Response<Vec<entities::Account>>, Error>;
async fn add_accounts_to_list(
&self,
id: String,
account_ids: Vec<String>,
) -> Result<Response<entities::List>, Error>;
async fn delete_accounts_from_list(
&self,
id: String,
account_ids: Vec<String>,
) -> Result<Response<()>, Error>;
async fn get_markers(&self, timeline: Vec<String>)
-> Result<Response<entities::Marker>, Error>;
async fn save_markers(
&self,
options: Option<&SaveMarkersInputOptions>,
) -> Result<Response<entities::Marker>, Error>;
async fn get_notifications(
&self,
options: Option<&GetNotificationsInputOptions>,
) -> Result<Response<Vec<entities::Notification>>, Error>;
async fn get_notification(&self, id: String)
-> Result<Response<entities::Notification>, Error>;
async fn dismiss_notifications(&self) -> Result<Response<()>, Error>;
async fn dismiss_notification(&self, id: String) -> Result<Response<()>, Error>;
async fn read_notifications(
&self,
options: &ReadNotificationsInputOptions,
) -> Result<Response<()>, Error>;
async fn subscribe_push_notification(
&self,
subscription: &SubscribePushNotificationInputSubscription,
data: Option<&SubscribePushNotificationInputData>,
) -> Result<Response<entities::PushSubscription>, Error>;
async fn get_push_subscription(&self) -> Result<Response<entities::PushSubscription>, Error>;
async fn update_push_subscription(
&self,
data: Option<&SubscribePushNotificationInputData>,
) -> Result<Response<entities::PushSubscription>, Error>;
async fn delete_push_subscription(&self) -> Result<Response<()>, Error>;
async fn search(
&self,
q: String,
options: Option<&SearchInputOptions>,
) -> Result<Response<entities::Results>, Error>;
async fn get_instance(&self) -> Result<Response<entities::Instance>, Error>;
async fn get_instance_peers(&self) -> Result<Response<Vec<String>>, Error>;
async fn get_instance_activity(&self) -> Result<Response<Vec<entities::Activity>>, Error>;
async fn get_instance_trends(
&self,
limit: Option<u32>,
) -> Result<Response<Vec<entities::Tag>>, Error>;
async fn get_instance_directory(
&self,
options: Option<&GetInstanceDirectoryInputOptions>,
) -> Result<Response<Vec<entities::Account>>, Error>;
async fn get_instance_custom_emojis(&self) -> Result<Response<Vec<entities::Emoji>>, Error>;
async fn get_instance_announcements(
&self,
) -> Result<Response<Vec<entities::Announcement>>, Error>;
async fn dismiss_instance_announcement(&self, id: String) -> Result<Response<()>, Error>;
async fn add_reaction_to_announcement(
&self,
id: String,
name: String,
) -> Result<Response<()>, Error>;
async fn remove_reaction_from_announcement(
&self,
id: String,
name: String,
) -> Result<Response<()>, Error>;
async fn create_emoji_reaction(
&self,
id: String,
emoji: String,
) -> Result<Response<entities::Status>, Error>;
async fn delete_emoji_reaction(
&self,
id: String,
emoji: String,
) -> Result<Response<entities::Status>, Error>;
async fn get_emoji_reactions(
&self,
id: String,
) -> Result<Response<Vec<entities::Reaction>>, Error>;
async fn get_emoji_reaction(
&self,
id: String,
emoji: String,
) -> Result<Response<entities::Reaction>, Error>;
async fn streaming_url(&self) -> String;
async fn user_streaming(&self) -> Box<dyn Streaming + Send + Sync>;
async fn public_streaming(&self) -> Box<dyn Streaming + Send + Sync>;
async fn local_streaming(&self) -> Box<dyn Streaming + Send + Sync>;
async fn direct_streaming(&self) -> Box<dyn Streaming + Send + Sync>;
async fn tag_streaming(&self, tag: String) -> Box<dyn Streaming + Send + Sync>;
async fn list_streaming(&self, list_id: String) -> Box<dyn Streaming + Send + Sync>;
}
#[derive(Debug, Clone, Default)]
pub struct AppInputOptions {
pub scopes: Option<Vec<String>>,
pub redirect_uris: Option<String>,
pub website: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct UpdateCredentialsInputOptions {
pub discoverable: Option<bool>,
pub bot: Option<bool>,
pub display_name: Option<String>,
pub note: Option<String>,
pub avatar: Option<String>,
pub header: Option<String>,
pub locked: Option<bool>,
pub source: Option<CredentialsSource>,
pub fields_attributes: Option<Vec<CredentialsFieldAttribute>>,
}
#[derive(Debug, Serialize, Clone, Default)]
pub struct CredentialsSource {
pub privacy: Option<String>,
pub sensitive: Option<bool>,
pub language: Option<String>,
}
#[derive(Debug, Serialize, Clone)]
pub struct CredentialsFieldAttribute {
pub name: String,
pub value: String,
}
#[derive(Debug, Clone, Default)]
pub struct GetAccountStatusesInputOptions {
pub limit: Option<u32>,
pub max_id: Option<String>,
pub since_id: Option<String>,
pub pinned: Option<bool>,
pub exclude_replies: Option<bool>,
pub exclude_reblogs: Option<bool>,
pub only_media: Option<bool>,
pub only_public: Option<bool>,
}
#[derive(Debug, Clone, Default)]
pub struct GetAccountFavouritesInputOptions {
pub limit: Option<u32>,
pub max_id: Option<String>,
pub since_id: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct AccountFollowersInputOptions {
pub limit: Option<u32>,
pub max_id: Option<String>,
pub since_id: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct FollowAccountInputOptions {
pub reblog: Option<bool>,
pub notify: Option<bool>,
}
#[derive(Debug, Clone, Default)]
pub struct SearchAccountInputOptions {
pub following: Option<bool>,
pub resolve: Option<bool>,
pub limit: Option<u32>,
pub max_id: Option<String>,
pub since_id: Option<String>,
}
pub type GetBookmarksInputOptions = GetArrayWithSinceOptions;
pub type GetFavouritesInputOptions = GetArrayOptions;
pub type GetMutesInputOptions = GetArrayOptions;
pub type GetBlocksInputOptions = GetArrayOptions;
pub type GetDomainBlocksInputOptions = GetArrayOptions;
#[derive(Debug, Clone, Default)]
pub struct GetArrayOptions {
pub limit: Option<u32>,
pub max_id: Option<String>,
pub min_id: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct GetArrayWithSinceOptions {
pub limit: Option<u32>,
pub max_id: Option<String>,
pub since_id: Option<String>,
pub min_id: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct FilterInputOptions {
pub irreversible: Option<bool>,
pub whole_word: Option<bool>,
pub expires_in: Option<u64>,
}
#[derive(Debug, Clone, Default)]
pub struct ReportInputOptions {
pub status_ids: Option<Vec<String>>,
pub comment: Option<String>,
pub forward: Option<bool>,
pub category: Option<entities::report::Category>,
pub rule_ids: Option<Vec<u64>>,
}
#[derive(Debug, Clone, Default)]
pub struct GetEndorsementsInputOptions {
pub limit: Option<u32>,
pub max_id: Option<String>,
pub since_id: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct PostStatusInputOptions {
pub media_ids: Option<Vec<String>>,
pub poll: Option<PollOptions>,
pub in_reply_to_id: Option<String>,
pub sensitive: Option<bool>,
pub spoiler_text: Option<String>,
pub visibility: Option<entities::status::StatusVisibility>,
pub scheduled_at: Option<DateTime<Utc>>,
pub language: Option<String>,
pub quote_id: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct EditStatusInputOptions {
pub status: Option<String>,
pub spoiler_text: Option<String>,
pub sensitive: Option<bool>,
pub language: Option<String>,
pub media_ids: Option<Vec<String>>,
pub poll: Option<PollOptions>,
}
#[derive(Debug, Serialize, Clone, Default)]
pub struct PollOptions {
pub options: Vec<String>,
pub expires_in: Option<u64>,
pub multiple: Option<bool>,
pub hide_totals: Option<bool>,
}
#[derive(Debug, Clone, Default)]
pub struct GetStatusContextInputOptions {
pub limit: Option<u32>,
pub max_id: Option<String>,
pub since_id: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct UploadMediaInputOptions {
pub description: Option<String>,
pub focus: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct UpdateMediaInputOptions {
pub file_path: Option<String>,
pub description: Option<String>,
pub focus: Option<String>,
}
pub type GetScheduledStatusesInputOptions = GetArrayWithSinceOptions;
pub type GetPublicTimelineInputOptions = GetTimelineOptions;
pub type GetLocalTimelineInputOptions = GetTimelineOptions;
pub type GetTagTimelineInputOptions = GetTimelineOptionsWithLocal;
pub type GetHomeTimelineInputOptions = GetTimelineOptionsWithLocal;
pub type GetListTimelineInputOptions = GetArrayWithSinceOptions;
pub type GetConversationTimelineInputOptions = GetArrayWithSinceOptions;
pub type GetAccountsInListInputOptions = GetArrayOptions;
#[derive(Debug, Clone, Default)]
pub struct GetTimelineOptions {
pub only_media: Option<bool>,
pub limit: Option<u32>,
pub max_id: Option<String>,
pub since_id: Option<String>,
pub min_id: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct GetTimelineOptionsWithLocal {
pub only_media: Option<bool>,
pub limit: Option<u32>,
pub max_id: Option<String>,
pub since_id: Option<String>,
pub min_id: Option<String>,
pub local: Option<bool>,
}
#[derive(Debug, Clone, Default)]
pub struct SaveMarkersInputOptions {
pub home: Option<Marker>,
pub notifications: Option<Marker>,
}
#[derive(Debug, Serialize, Clone)]
pub struct Marker {
pub last_reading_id: String,
}
#[derive(Debug, Clone, Default)]
pub struct GetNotificationsInputOptions {
pub limit: Option<u32>,
pub max_id: Option<String>,
pub since_id: Option<String>,
pub min_id: Option<String>,
pub exclude_types: Option<Vec<entities::notification::NotificationType>>,
pub account_id: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct ReadNotificationsInputOptions {
pub id: Option<String>,
pub max_id: Option<String>,
}
#[derive(Debug, Serialize, Clone)]
pub struct SubscribePushNotificationInputSubscription {
pub endpoint: String,
pub keys: SubscriptionKeys,
}
#[derive(Debug, Serialize, Clone)]
pub struct SubscriptionKeys {
pub p256h: String,
pub auth: String,
}
#[derive(Debug, Serialize, Clone, Default)]
pub struct SubscribePushNotificationInputData {
pub alerts: Option<DataAlerts>,
}
#[derive(Debug, Serialize, Clone, Default)]
pub struct DataAlerts {
pub follow: Option<bool>,
pub favourite: Option<bool>,
pub reblog: Option<bool>,
pub mention: Option<bool>,
pub poll: Option<bool>,
}
#[derive(Debug, Clone)]
pub enum SearchType {
Accounts,
Hashtags,
Statuses,
}
impl fmt::Display for SearchType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
SearchType::Accounts => write!(f, "accounts"),
SearchType::Hashtags => write!(f, "hashtags"),
SearchType::Statuses => write!(f, "statuses"),
}
}
}
impl FromStr for SearchType {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"accounts" => Ok(SearchType::Accounts),
"hashtags" => Ok(SearchType::Hashtags),
"statuses" => Ok(SearchType::Statuses),
_ => Err(Error::new_own(
s.to_owned(),
Kind::ParseError,
None,
None,
None,
)),
}
}
}
#[derive(Debug, Clone, Default)]
pub struct SearchInputOptions {
pub r#type: Option<SearchType>,
pub limit: Option<u32>,
pub max_id: Option<String>,
pub min_id: Option<String>,
pub resolve: Option<bool>,
pub offset: Option<u64>,
pub following: Option<bool>,
pub account_id: Option<String>,
pub exclude_unreviewed: Option<bool>,
}
#[derive(Debug, Clone, Default)]
pub struct GetInstanceDirectoryInputOptions {
pub limit: Option<u32>,
pub offset: Option<u64>,
pub order: Option<Order>,
pub local: Option<bool>,
}
#[derive(Debug, Clone)]
pub enum Order {
Active,
New,
}
impl fmt::Display for Order {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Order::Active => write!(f, "active"),
Order::New => write!(f, "new"),
}
}
}
impl FromStr for Order {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"active" => Ok(Order::Active),
"new" => Ok(Order::New),
_ => Err(Error::new_own(
s.to_owned(),
Kind::ParseError,
None,
None,
None,
)),
}
}
}
#[derive(Debug, Clone)]
pub enum FollowRequestOutput {
Account(entities::Account),
FollowRequest(entities::FollowRequest),
}
#[derive(Debug, Clone)]
pub enum PostStatusOutput {
Status(entities::Status),
ScheduledStatus(entities::ScheduledStatus),
}