diff options
author | D. Scott Boggs <scott@tams.tech> | 2023-01-04 08:54:03 -0500 |
---|---|---|
committer | Scott Boggs <dscottboggs@gmail.com> | 2023-01-09 07:27:53 -0500 |
commit | 14dc17e58268ff76d3a627e0dff21982499461a1 (patch) | |
tree | 93678d0eecc78f87c70b3d8d05a8b8e40575fa92 | |
parent | cc6bd77cab570c970edc8041bb8a0a0d2a076115 (diff) |
Split status_builder module into a few files
-rw-r--r-- | entities/src/filter.rs | 2 | ||||
-rw-r--r-- | src/status_builder/mod.rs (renamed from src/status_builder.rs) | 46 | ||||
-rw-r--r-- | src/status_builder/new_status.rs | 43 |
3 files changed, 49 insertions, 42 deletions
diff --git a/entities/src/filter.rs b/entities/src/filter.rs index 751e45c..e844b42 100644 --- a/entities/src/filter.rs +++ b/entities/src/filter.rs @@ -176,8 +176,10 @@ mod v1 { #[cfg(test)] mod tests { + #[cfg(feature = "json")] use super::*; + #[cfg(feature = "json")] #[test] fn test_filter_action_serialize_and_deserialize() { use Action::*; diff --git a/src/status_builder.rs b/src/status_builder/mod.rs index fb1b2eb..0a7e6f8 100644 --- a/src/status_builder.rs +++ b/src/status_builder/mod.rs @@ -1,7 +1,9 @@ +mod new_status; + use isolang::Language; -use serde::Serialize; -pub use mastodon_async_entities::visibility::Visibility; +pub use self::new_status::NewStatus; +use mastodon_async_entities::visibility::Visibility; /// A builder pattern struct for constructing a status. /// @@ -219,46 +221,6 @@ impl StatusBuilder { } } -/// Represents a post that can be sent to the POST /api/v1/status endpoint -/// -/// See also [the API documentation](https://docs.joinmastodon.org/methods/statuses/#form-data-parameters) -#[derive(Debug, Default, Clone, Serialize, PartialEq, Eq)] -pub struct NewStatus { - /// The text content of the status. If media_ids is provided, this becomes - /// optional. Attaching a poll is optional while status is provided. - /// - /// Note that this means there is at this time no check provided by this - /// type to ensure that this value is set when it is required by the API, - /// and an APIError should be expected from [`crate::Mastodon::new_status()`] - /// in this case. - #[serde(skip_serializing_if = "Option::is_none")] - pub status: Option<String>, - /// ID of the status being replied to, if status is a reply. - #[serde(skip_serializing_if = "Option::is_none")] - pub in_reply_to_id: Option<String>, - /// Include Attachment IDs to be attached as media. If provided, status - /// becomes optional, and poll cannot be used. - #[serde(skip_serializing_if = "Option::is_none")] - pub media_ids: Option<Vec<String>>, - /// Mark status and attached media as sensitive? Defaults to false. - #[serde(skip_serializing_if = "Option::is_none")] - pub sensitive: Option<bool>, - #[serde(skip_serializing_if = "Option::is_none")] - /// Text to be shown as a warning or subject before the actual content. - /// Statuses are generally collapsed behind this field. - pub spoiler_text: Option<String>, - /// Sets the visibility of the posted status to public, unlisted, private, direct. - #[serde(skip_serializing_if = "Option::is_none")] - pub visibility: Option<Visibility>, - /// ISO 639 language code for this status. - #[serde(skip_serializing_if = "Option::is_none")] - pub language: Option<Language>, - /// Ignored by Mastodon servers, sets the content type for the status. - /// Mastodon "toots" are always `text/plain`, regardless of this value. - #[serde(skip_serializing_if = "Option::is_none")] - pub content_type: Option<String>, -} - #[cfg(test)] mod tests { use super::*; diff --git a/src/status_builder/new_status.rs b/src/status_builder/new_status.rs new file mode 100644 index 0000000..43e5466 --- /dev/null +++ b/src/status_builder/new_status.rs @@ -0,0 +1,43 @@ +use isolang::Language; + +use mastodon_async_entities::visibility::Visibility; + +/// Represents a post that can be sent to the POST /api/v1/status endpoint +/// +/// See also [the API documentation](https://docs.joinmastodon.org/methods/statuses/#form-data-parameters) +#[derive(Debug, Default, Clone, Serialize, PartialEq, Eq)] +pub struct NewStatus { + /// The text content of the status. If media_ids is provided, this becomes + /// optional. Attaching a poll is optional while status is provided. + /// + /// Note that this means there is at this time no check provided by this + /// type to ensure that this value is set when it is required by the API, + /// and an APIError should be expected from [`crate::Mastodon::new_status()`] + /// in this case. + #[serde(skip_serializing_if = "Option::is_none")] + pub status: Option<String>, + /// ID of the status being replied to, if status is a reply. + #[serde(skip_serializing_if = "Option::is_none")] + pub in_reply_to_id: Option<String>, + /// Include Attachment IDs to be attached as media. If provided, status + /// becomes optional, and poll cannot be used. + #[serde(skip_serializing_if = "Option::is_none")] + pub media_ids: Option<Vec<String>>, + /// Mark status and attached media as sensitive? Defaults to false. + #[serde(skip_serializing_if = "Option::is_none")] + pub sensitive: Option<bool>, + #[serde(skip_serializing_if = "Option::is_none")] + /// Text to be shown as a warning or subject before the actual content. + /// Statuses are generally collapsed behind this field. + pub spoiler_text: Option<String>, + /// Sets the visibility of the posted status to public, unlisted, private, direct. + #[serde(skip_serializing_if = "Option::is_none")] + pub visibility: Option<Visibility>, + /// ISO 639 language code for this status. + #[serde(skip_serializing_if = "Option::is_none")] + pub language: Option<Language>, + /// Ignored by Mastodon servers, sets the content type for the status. + /// Mastodon "toots" are always `text/plain`, regardless of this value. + #[serde(skip_serializing_if = "Option::is_none")] + pub content_type: Option<String>, +} |