impl PartialDiscordFileAttachment
Now contains move_$ methods, which can move individual values out of the PartialDiscordFileAttachment while preserving the rest of the object.
This commit is contained in:
parent
c544bd409d
commit
6732640f96
|
@ -847,7 +847,7 @@ pub struct DiscordFileAttachment {
|
|||
|
||||
pub struct PartialDiscordFileAttachment {
|
||||
pub id: Option<i16>,
|
||||
pub filename: Option<String>,
|
||||
pub filename: String,
|
||||
pub description: Option<String>,
|
||||
pub content_type: Option<String>,
|
||||
pub size: Option<i64>,
|
||||
|
@ -862,6 +862,73 @@ pub struct PartialDiscordFileAttachment {
|
|||
pub content: Vec<u8>,
|
||||
}
|
||||
|
||||
impl PartialDiscordFileAttachment {
|
||||
/**
|
||||
Moves `self.content` out of `self` and returns it.
|
||||
# Returns
|
||||
Vec<u8>
|
||||
*/
|
||||
pub fn move_content(self) -> (Vec<u8>, 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<String>, 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<AllowedMentionType>,
|
||||
|
|
Loading…
Reference in New Issue