Document a small bit of attachment
This commit is contained in:
parent
590afc8c9d
commit
d50e969a07
|
@ -4,9 +4,12 @@ use crate::types::utils::Snowflake;
|
|||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
|
||||
/// # Reference
|
||||
/// See <https://discord.com/developers/docs/resources/channel#attachment-object>
|
||||
pub struct Attachment {
|
||||
pub id: Snowflake,
|
||||
pub filename: String,
|
||||
/// Max 1024 characters
|
||||
pub description: Option<String>,
|
||||
pub content_type: Option<String>,
|
||||
pub size: u64,
|
||||
|
@ -15,7 +18,13 @@ pub struct Attachment {
|
|||
pub height: Option<u64>,
|
||||
pub width: Option<u64>,
|
||||
pub ephemeral: Option<bool>,
|
||||
/// The duration of the audio file (only for voice messages)
|
||||
pub duration_secs: Option<f32>,
|
||||
/// A Base64 encoded bytearray representing a sampled waveform (only for voice messages)
|
||||
///
|
||||
/// # Notes
|
||||
/// Note that this is computed on the client side.
|
||||
/// This means it can be spoofed and isn't necessarily accurate.
|
||||
pub waveform: Option<String>,
|
||||
#[serde(skip_serializing)]
|
||||
#[cfg_attr(feature = "sqlx", sqlx(default))]
|
||||
|
@ -26,6 +35,7 @@ pub struct Attachment {
|
|||
pub struct PartialDiscordFileAttachment {
|
||||
pub id: Option<i16>,
|
||||
pub filename: String,
|
||||
/// Max 1024 characters
|
||||
pub description: Option<String>,
|
||||
pub content_type: Option<String>,
|
||||
pub size: Option<i64>,
|
||||
|
@ -34,7 +44,13 @@ pub struct PartialDiscordFileAttachment {
|
|||
pub height: Option<i32>,
|
||||
pub width: Option<i32>,
|
||||
pub ephemeral: Option<bool>,
|
||||
/// The duration of the audio file (only for voice messages)
|
||||
pub duration_secs: Option<f32>,
|
||||
/// A Base64 encoded bytearray representing a sampled waveform (only for voice messages)
|
||||
///
|
||||
/// # Notes
|
||||
/// Note that this is computed on the client side.
|
||||
/// This means it can be spoofed and isn't necessarily accurate.
|
||||
pub waveform: Option<String>,
|
||||
#[serde(skip_serializing)]
|
||||
pub content: Vec<u8>,
|
||||
|
@ -62,6 +78,7 @@ impl PartialDiscordFileAttachment {
|
|||
(content, updated_struct)
|
||||
}
|
||||
|
||||
/// Moves `self.filename` out of `self` and returns it.
|
||||
pub fn move_filename(self) -> (String, PartialDiscordFileAttachment) {
|
||||
let filename = self.filename;
|
||||
let updated_struct = PartialDiscordFileAttachment {
|
||||
|
@ -83,6 +100,7 @@ impl PartialDiscordFileAttachment {
|
|||
(filename, updated_struct)
|
||||
}
|
||||
|
||||
/// Moves `self.content_type` out of `self` and returns it.
|
||||
pub fn move_content_type(self) -> (Option<String>, PartialDiscordFileAttachment) {
|
||||
let content_type = self.content_type;
|
||||
let updated_struct = PartialDiscordFileAttachment {
|
||||
|
|
Loading…
Reference in New Issue