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