diff options
author | D. Scott Boggs <scott@tams.tech> | 2023-01-26 05:16:41 -0500 |
---|---|---|
committer | Scott Boggs <dscottboggs@gmail.com> | 2023-01-29 06:13:53 -0500 |
commit | 5f5bc8728c5db17eb12dbfc8a33c4f6da544ec01 (patch) | |
tree | 91d57af2b9b417f2317f3062e4567bf10f5c279b | |
parent | b6fd884387a78b37026c60764ad00286888e98a7 (diff) |
Add alias/convenience method
-rw-r--r-- | entities/src/attachment.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/entities/src/attachment.rs b/entities/src/attachment.rs index 32c42a2..772b160 100644 --- a/entities/src/attachment.rs +++ b/entities/src/attachment.rs @@ -27,6 +27,18 @@ pub struct Attachment { pub description: Option<String>, } +impl Attachment { + /// If this is an attachment which was either processed synchronously or + /// in some other way has finished processing before being deserialized, + /// `url` will be present. This is a convenience method to indicate that + /// state. + /// + /// If possible, it's recommended instead to use + /// [`Mastodon::wait_for_processing()`](https://docs.rs/mastodon-async/latest/mastodon_async/mastodon/struct.Mastodon.html#method.wait_for_processing). + pub fn is_done_processing(&self) -> bool { + self.url.is_some() + } +} /// Wrapper type for a attachment ID string #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] #[serde(transparent)] |