diff options
Diffstat (limited to 'src/model/id.rs')
| -rw-r--r-- | src/model/id.rs | 67 |
1 files changed, 51 insertions, 16 deletions
diff --git a/src/model/id.rs b/src/model/id.rs index 3d8c20c..4e2fbc3 100644 --- a/src/model/id.rs +++ b/src/model/id.rs @@ -7,13 +7,8 @@ use std::fmt::{Display, Formatter, Result as FmtResult}; use super::utils::U64Visitor; macro_rules! id_u64 { - ($(#[$attr:meta] $name:ident;)*) => { + ($($name:ident;)*) => { $( - #[$attr] - #[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] - #[allow(derive_hash_xor_eq)] - pub struct $name(pub u64); - impl $name { /// Retrieves the time that the Id was created at. pub fn created_at(&self) -> NaiveDateTime { @@ -65,25 +60,65 @@ macro_rules! id_u64 { } } +/// An identifier for an Application. +#[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] +#[allow(derive_hash_xor_eq)] +pub struct ApplicationId(pub u64); + +/// An identifier for a Channel +#[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] +#[allow(derive_hash_xor_eq)] +pub struct ChannelId(pub u64); + +/// An identifier for an Emoji +#[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] +#[allow(derive_hash_xor_eq)] +pub struct EmojiId(pub u64); + +/// An identifier for a Guild +#[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] +#[allow(derive_hash_xor_eq)] +pub struct GuildId(pub u64); + +/// An identifier for an Integration +#[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] +#[allow(derive_hash_xor_eq)] +pub struct IntegrationId(pub u64); + +/// An identifier for a Message +#[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] +#[allow(derive_hash_xor_eq)] +pub struct MessageId(pub u64); + +/// An identifier for a Role +#[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] +#[allow(derive_hash_xor_eq)] +pub struct RoleId(pub u64); + +/// An identifier for a User +#[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] +#[allow(derive_hash_xor_eq)] +pub struct UserId(pub u64); + +/// An identifier for a [`Webhook`](struct.Webhook.html). +#[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] +#[allow(derive_hash_xor_eq)] +pub struct WebhookId(pub u64); + +/// An identifier for an audit log entry. +#[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] +#[allow(derive_hash_xor_eq)] +pub struct AuditLogEntryId(pub u64); + id_u64! { - /// An identifier for an Application. ApplicationId; - /// An identifier for a Channel ChannelId; - /// An identifier for an Emoji EmojiId; - /// An identifier for a Guild GuildId; - /// An identifier for an Integration IntegrationId; - /// An identifier for a Message MessageId; - /// An identifier for a Role RoleId; - /// An identifier for a User UserId; - /// An identifier for a [`Webhook`](struct.Webhook.html). WebhookId; - /// An identifier for an audit log entry. AuditLogEntryId; } |