diff --git a/src/api/types.rs b/src/api/types.rs index 00d47a7..5322b95 100644 --- a/src/api/types.rs +++ b/src/api/types.rs @@ -847,7 +847,7 @@ pub struct DiscordFileAttachment { pub struct PartialDiscordFileAttachment { pub id: Option, - pub filename: Option, + pub filename: String, pub description: Option, pub content_type: Option, pub size: Option, @@ -862,6 +862,73 @@ pub struct PartialDiscordFileAttachment { pub content: Vec, } +impl PartialDiscordFileAttachment { + /** + Moves `self.content` out of `self` and returns it. + # Returns + Vec + */ + pub fn move_content(self) -> (Vec, PartialDiscordFileAttachment) { + let content = self.content; + let updated_struct = PartialDiscordFileAttachment { + id: self.id, + filename: self.filename, + description: self.description, + content_type: self.content_type, + size: self.size, + url: self.url, + proxy_url: self.proxy_url, + height: self.height, + width: self.width, + ephemeral: self.ephemeral, + duration_secs: self.duration_secs, + waveform: self.waveform, + content: Vec::new(), + }; + (content, updated_struct) + } + + pub fn move_filename(self) -> (String, PartialDiscordFileAttachment) { + let filename = self.filename; + let updated_struct = PartialDiscordFileAttachment { + id: self.id, + filename: String::new(), + description: self.description, + content_type: self.content_type, + size: self.size, + url: self.url, + proxy_url: self.proxy_url, + height: self.height, + width: self.width, + ephemeral: self.ephemeral, + duration_secs: self.duration_secs, + waveform: self.waveform, + content: self.content, + }; + (filename, updated_struct) + } + + pub fn move_content_type(self) -> (Option, PartialDiscordFileAttachment) { + let content_type = self.content_type; + let updated_struct = PartialDiscordFileAttachment { + id: self.id, + filename: self.filename, + description: self.description, + content_type: None, + size: self.size, + url: self.url, + proxy_url: self.proxy_url, + height: self.height, + width: self.width, + ephemeral: self.ephemeral, + duration_secs: self.duration_secs, + waveform: self.waveform, + content: self.content, + }; + (content_type, updated_struct) + } +} + #[derive(Debug, Serialize, Deserialize)] pub struct AllowedMention { parse: Vec,