docs(all): Added documentation to missing parts
This commit is contained in:
+28
-8
@@ -1,19 +1,39 @@
|
||||
//! A module containing everything relating to a account returned from the api.
|
||||
|
||||
use chrono::prelude::*;
|
||||
|
||||
/// A struct representing an Account.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Account {
|
||||
pub id: u64,
|
||||
pub username: String,
|
||||
/// Equals `username` for local users, includes `@domain` for remote ones.
|
||||
pub acct: String,
|
||||
pub display_name: String,
|
||||
pub note: String,
|
||||
pub url: String,
|
||||
/// URL to the avatar image
|
||||
pub avatar: String,
|
||||
/// URL to the avatar static image (gif)
|
||||
pub avatar_static: String,
|
||||
pub header: String,
|
||||
pub header_static: String,
|
||||
pub locked: bool,
|
||||
/// The time the account was created.
|
||||
pub created_at: DateTime<Utc>,
|
||||
/// The account's display name.
|
||||
pub display_name: String,
|
||||
/// The number of followers for the account.
|
||||
pub followers_count: u64,
|
||||
/// The number of accounts the given account is following.
|
||||
pub following_count: u64,
|
||||
/// URL to the header image.
|
||||
pub header: String,
|
||||
/// URL to the header static image (gif).
|
||||
pub header_static: String,
|
||||
/// The ID of the account.
|
||||
pub id: u64,
|
||||
/// Boolean for when the account cannot be followed without waiting for
|
||||
/// approval first.
|
||||
pub locked: bool,
|
||||
/// Biography of user.
|
||||
pub note: String,
|
||||
/// The number of statuses the account has made.
|
||||
pub statuses_count: u64,
|
||||
/// URL of the user's profile page (can be remote).
|
||||
pub url: String,
|
||||
/// The username of the account.
|
||||
pub username: String,
|
||||
}
|
||||
|
||||
@@ -1,39 +1,64 @@
|
||||
//! Module containing everything related to media attachements.
|
||||
|
||||
/// A struct representing a media attachment.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Attachment {
|
||||
/// ID of the attachment.
|
||||
pub id: String,
|
||||
/// The media type of an attachment.
|
||||
#[serde(rename="type")]
|
||||
pub media_type: MediaType,
|
||||
/// URL of the locally hosted version of the image.
|
||||
pub url: String,
|
||||
/// For remote images, the remote URL of the original image.
|
||||
pub remote_url: Option<String>,
|
||||
/// URL of the preview image.
|
||||
pub preview_url: String,
|
||||
/// Shorter URL for the image, for insertion into text
|
||||
/// (only present on local images)
|
||||
pub text_url: Option<String>,
|
||||
/// Meta information about the attachment.
|
||||
pub meta: Option<Meta>,
|
||||
/// Noop will be removed.
|
||||
pub description: Option<String>,
|
||||
}
|
||||
|
||||
/// Information about the attachment itself.
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct Meta {
|
||||
/// Original version.
|
||||
original: ImageDetails,
|
||||
/// Smaller version.
|
||||
small: ImageDetails,
|
||||
}
|
||||
|
||||
/// Dimensions of an attachement.
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct ImageDetails {
|
||||
/// width of attachment.
|
||||
width: u64,
|
||||
/// height of attachment.
|
||||
height: u64,
|
||||
/// A string of `widthxheight`.
|
||||
size: String,
|
||||
/// The aspect ratio of the attachment.
|
||||
aspect: f64,
|
||||
|
||||
}
|
||||
|
||||
/// The type of media attachment.
|
||||
#[derive(Debug, Deserialize, Clone, Copy)]
|
||||
pub enum MediaType {
|
||||
/// An image.
|
||||
#[serde(rename = "image")]
|
||||
Image,
|
||||
/// A video file.
|
||||
#[serde(rename = "video")]
|
||||
Video,
|
||||
/// A gifv format file.
|
||||
#[serde(rename = "gifv")]
|
||||
Gifv,
|
||||
/// Unknown format.
|
||||
#[serde(rename = "unknown")]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
//! Module representing cards of statuses.
|
||||
|
||||
/// A card of a status.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Card {
|
||||
/// The url associated with the card.
|
||||
pub url: String,
|
||||
/// The title of the card.
|
||||
pub title: String,
|
||||
/// The card description.
|
||||
pub description: String,
|
||||
/// The image associated with the card, if any.
|
||||
pub image: String,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
//! A module about contexts of statuses.
|
||||
|
||||
use super::status::Status;
|
||||
|
||||
/// A context of a status returning a list of statuses it replied to and
|
||||
/// statuses replied to it.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Context {
|
||||
/// Statuses that were replied to.
|
||||
pub ancestors: Vec<Status>,
|
||||
/// Statuses that replied to this status.
|
||||
pub descendants: Vec<Status>,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
//! Module containing everything related to an instance.
|
||||
|
||||
/// A struct containing info of an instance.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Instance {
|
||||
/// URI of the current instance
|
||||
pub uri: String,
|
||||
/// The instance's title.
|
||||
pub title: String,
|
||||
/// A description for the instance.
|
||||
pub description: String,
|
||||
/// An email address which can be used to contact the
|
||||
/// instance administrator.
|
||||
pub email: String,
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ pub mod status;
|
||||
pub struct Empty {}
|
||||
|
||||
pub mod prelude {
|
||||
//! The purpose of this module is to alleviate imports of many common structs
|
||||
//! by adding a glob import to the top of mastodon heavy modules:
|
||||
pub use super::Empty;
|
||||
pub use super::account::Account;
|
||||
pub use super::attachment::{Attachment, MediaType};
|
||||
|
||||
@@ -1,25 +1,38 @@
|
||||
//! Module containing all info about notifications.
|
||||
|
||||
use chrono::prelude::*;
|
||||
use super::account::Account;
|
||||
use super::status::Status;
|
||||
|
||||
/// A struct containing info about a notification.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Notification {
|
||||
/// The notification ID.
|
||||
pub id: u64,
|
||||
/// The type of notification.
|
||||
#[serde(rename = "type")]
|
||||
pub notification_type: NotificationType,
|
||||
/// The time the notification was created.
|
||||
pub created_at: DateTime<Utc>,
|
||||
/// The Account sending the notification to the user.
|
||||
pub account: Account,
|
||||
/// The Status associated with the notification, if applicable.
|
||||
pub status: Option<Status>,
|
||||
}
|
||||
|
||||
/// The type of notification.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub enum NotificationType {
|
||||
/// Someone mentioned the application client in another status.
|
||||
#[serde(rename = "mention")]
|
||||
Mention,
|
||||
/// Someone reblogged one of the application client's statuses.
|
||||
#[serde(rename = "reblog")]
|
||||
Reblog,
|
||||
/// Someone favourited one of the application client's statuses.
|
||||
#[serde(rename = "favourite")]
|
||||
Favourite,
|
||||
/// Someone followed the application client.
|
||||
#[serde(rename = "follow")]
|
||||
Follow,
|
||||
}
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
//! module containing everything relating to a relationship with
|
||||
//! another account.
|
||||
|
||||
/// A struct containing information about a relationship with another account.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Relationship {
|
||||
/// Whether the application client follows the account.
|
||||
pub following: bool,
|
||||
/// Whether the account follows the application client.
|
||||
pub followed_by: bool,
|
||||
/// Whether the application client blocks the account.
|
||||
pub blocking: bool,
|
||||
/// Whether the application client blocks the account.
|
||||
pub muting: bool,
|
||||
/// Whether the application client has requested to follow the account.
|
||||
pub requested: bool,
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
//! module containing information about a finished report of a user.
|
||||
|
||||
/// A struct containing info about a report.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Report {
|
||||
/// The ID of the report.
|
||||
pub id: u64,
|
||||
/// The action taken in response to the report.
|
||||
pub action_taken: String,
|
||||
}
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
//! A module containing info relating to a search result.
|
||||
|
||||
use super::prelude::{Account, Status};
|
||||
|
||||
/// A struct containing results of a search.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct SearchResult {
|
||||
/// An array of matched Accounts.
|
||||
pub accounts: Vec<Account>,
|
||||
/// An array of matched Statuses.
|
||||
pub statuses: Vec<Status>,
|
||||
/// An array of matched hashtags, as strings.
|
||||
pub hashtags: Vec<String>,
|
||||
}
|
||||
|
||||
+39
-1
@@ -1,47 +1,85 @@
|
||||
//! Module containing all info relating to a status.
|
||||
|
||||
use chrono::prelude::*;
|
||||
use super::prelude::*;
|
||||
use status_builder::Visibility;
|
||||
|
||||
/// A status from the instance.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Status {
|
||||
/// The ID of the status.
|
||||
pub id: i64,
|
||||
/// A Fediverse-unique resource ID.
|
||||
pub uri: String,
|
||||
/// URL to the status page (can be remote)
|
||||
pub url: String,
|
||||
/// The Account which posted the status.
|
||||
pub account: Account,
|
||||
/// The ID of the status this status is replying to, if the status is
|
||||
/// a reply.
|
||||
pub in_reply_to_id: Option<u64>,
|
||||
/// The ID of the account this status is replying to, if the status is
|
||||
/// a reply.
|
||||
pub in_reply_to_account_id: Option<u64>,
|
||||
/// If this status is a reblogged Status of another User.
|
||||
pub reblog: Option<Box<Status>>,
|
||||
/// Body of the status; this will contain HTML
|
||||
/// (remote HTML already sanitized)
|
||||
pub content: String,
|
||||
/// The time the status was created.
|
||||
pub created_at: DateTime<Utc>,
|
||||
/// The number of reblogs for the status.
|
||||
pub reblogs_count: u64,
|
||||
/// The number of favourites for the status.
|
||||
pub favourites_count: u64,
|
||||
/// Whether the application client has reblogged the status.
|
||||
pub reblogged: Option<bool>,
|
||||
/// Whether the application client has favourited the status.
|
||||
pub favourited: Option<bool>,
|
||||
pub sensitive: Option<bool>,
|
||||
/// Whether media attachments should be hidden by default.
|
||||
pub sensitive: bool,
|
||||
/// If not empty, warning text that should be displayed before the actual
|
||||
/// content.
|
||||
pub spoiler_text: String,
|
||||
/// The visibilty of the status.
|
||||
pub visibility: Visibility,
|
||||
/// An array of attachments.
|
||||
pub media_attachments: Vec<Attachment>,
|
||||
/// An array of mentions.
|
||||
pub mentions: Vec<Mention>,
|
||||
/// An array of tags.
|
||||
pub tags: Vec<Tag>,
|
||||
/// Name of application used to post status.
|
||||
pub application: Option<Application>,
|
||||
}
|
||||
|
||||
/// A mention of another user.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Mention {
|
||||
/// URL of user's profile (can be remote).
|
||||
pub url: String,
|
||||
/// The username of the account.
|
||||
pub username: String,
|
||||
/// Equals `username` for local users, includes `@domain` for remote ones.
|
||||
pub acct: String,
|
||||
/// Account ID.
|
||||
pub id: u64,
|
||||
}
|
||||
|
||||
/// Hashtags in the status.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Tag {
|
||||
/// The hashtag, not including the preceding `#`.
|
||||
pub name: String,
|
||||
/// The URL of the hashtag.
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
/// Application details.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Application {
|
||||
/// Name of the application.
|
||||
pub name: String,
|
||||
/// Homepage URL of the application.
|
||||
pub website: Option<String>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user