mastodon API rust lib elefren, fixed and updated. and also all ASYNC! NB. most examples are now wrong.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
elefren-fork/src/status_builder.rs

59 lines
1.7 KiB

/// A builder pattern struct for constructing a status.
8 years ago
#[derive(Debug, Default, Clone, Serialize)]
pub struct StatusBuilder {
/// The text of the status.
pub status: String,
/// Ids of accounts being replied to.
8 years ago
#[serde(skip_serializing_if="Option::is_none")]
pub in_reply_to_id: Option<u64>,
/// Ids of media attachments being attached to the status.
8 years ago
#[serde(skip_serializing_if="Option::is_none")]
pub media_ids: Option<Vec<u64>>,
/// Whether current status is sensitive.
8 years ago
#[serde(skip_serializing_if="Option::is_none")]
pub sensitive: Option<bool>,
/// Text to precede the normal status text.
8 years ago
#[serde(skip_serializing_if="Option::is_none")]
pub spoiler_text: Option<String>,
/// Visibility of the status, defaults to `Public`.
8 years ago
#[serde(skip_serializing_if="Option::is_none")]
pub visibility: Option<Visibility>,
8 years ago
}
/// The visibility of a status.
8 years ago
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub enum Visibility {
/// A Direct message to a user
8 years ago
#[serde(rename = "direct")]
Direct,
/// Only available to followers
8 years ago
#[serde(rename = "private")]
Private,
/// Not shown in public timelines
8 years ago
#[serde(rename = "unlisted")]
Unlisted,
/// Posted to public timelines
8 years ago
#[serde(rename = "public")]
Public,
}
impl StatusBuilder {
/// Create a new status with text.
/// ```
/// let status = StatusBuilder::new("Hello World!".into());
/// ```
8 years ago
pub fn new(status: String) -> Self {
StatusBuilder {
status: status,
..Self::default()
}
}
}
impl Default for Visibility {
fn default() -> Self {
Visibility::Public
}
}