Compare commits

..

5 Commits

Author SHA1 Message Date
bitfl0wer bf94b9c04c
Try: Derive Type, FromRow for Tag 2024-08-20 15:44:26 +02:00
bitfl0wer f31c7298d8
Try: Derive Type for CustomStatus 2024-08-20 15:43:17 +02:00
bitfl0wer 28154c3c53
Try: Derive FromRow, Type for DefaultReaction 2024-08-20 15:41:36 +02:00
bitfl0wer 3fed76bb99
Try: derive Type for FriendSourceFlags, GuildFolder 2024-08-20 15:39:28 +02:00
bitfl0wer a561b61321
impl sqlx::postgres::PgHasArrayType for Snowflake 2024-08-20 15:28:27 +02:00
3 changed files with 16 additions and 3 deletions

View File

@ -171,6 +171,8 @@ fn compare_permission_overwrites(
///
/// # Reference
/// See <https://discord-userdoccers.vercel.app/resources/channel#forum-tag-object>
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow, sqlx::Type))]
#[cfg_attr(feature = "sqlx", sqlx(type_name = "interface_type"))]
pub struct Tag {
pub id: Snowflake,
/// The name of the tag (max 20 characters)
@ -317,6 +319,8 @@ impl PartialEq for ThreadMember {
///
/// # Reference
/// See <https://discord-userdoccers.vercel.app/resources/channel#default-reaction-object>
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow, sqlx::Type))]
#[cfg_attr(feature = "sqlx", sqlx(type_name = "interface_type"))]
pub struct DefaultReaction {
#[serde(default)]
pub emoji_id: Option<Snowflake>,

View File

@ -130,7 +130,8 @@ impl Default for UserSettings {
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow, sqlx::Type))]
#[cfg_attr(feature = "sqlx", sqlx(type_name = "interface_type"))]
pub struct CustomStatus {
pub emoji_id: Option<String>,
pub emoji_name: Option<String>,
@ -140,7 +141,7 @@ pub struct CustomStatus {
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Copy, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow, sqlx::Type))]
pub struct FriendSourceFlags {
pub all: bool,
}
@ -152,7 +153,8 @@ impl Default for FriendSourceFlags {
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow, sqlx::Type))]
#[cfg_attr(feature = "sqlx", sqlx(type_name = "interface_type"))]
pub struct GuildFolder {
#[cfg(not(feature = "sqlx"))]
pub color: Option<u32>,

View File

@ -102,6 +102,13 @@ impl sqlx::Type<sqlx::Postgres> for Snowflake {
}
}
#[cfg(feature = "sqlx")]
impl sqlx::postgres::PgHasArrayType for Snowflake {
fn array_type_info() -> sqlx::postgres::PgTypeInfo {
<Vec<String> as sqlx::Type<sqlx::Postgres>>::type_info()
}
}
#[cfg(feature = "sqlx")]
impl<'q> sqlx::Encode<'q, sqlx::Postgres> for Snowflake {
fn encode_by_ref(