From 5f5bc8728c5db17eb12dbfc8a33c4f6da544ec01 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Thu, 26 Jan 2023 05:16:41 -0500 Subject: [PATCH] Add alias/convenience method --- entities/src/attachment.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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, } +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)]