| 1 | //! Enumeration of all supported IRCv3 capability extensions. |
| 2 | |
| 3 | /// List of all supported IRCv3 capability extensions from the |
| 4 | /// [IRCv3 specifications](http://ircv3.net/irc/). |
| 5 | #[derive(Debug, PartialEq)] |
| 6 | pub enum Capability { |
| 7 | /// [multi-prefix](http://ircv3.net/specs/extensions/multi-prefix-3.1.html) |
| 8 | MultiPrefix, |
| 9 | /// [sasl](http://ircv3.net/specs/extensions/sasl-3.1.html) |
| 10 | Sasl, |
| 11 | /// [account-notify](http://ircv3.net/specs/extensions/account-notify-3.1.html) |
| 12 | AccountNotify, |
| 13 | /// [away-notify](http://ircv3.net/specs/extensions/away-notify-3.1.html) |
| 14 | AwayNotify, |
| 15 | /// [extended-join](http://ircv3.net/specs/extensions/extended-join-3.1.html) |
| 16 | ExtendedJoin, |
| 17 | /// [metadata](http://ircv3.net/specs/core/metadata-3.2.html) |
| 18 | Metadata, |
| 19 | /// [metadata-notify](http://ircv3.net/specs/core/metadata-3.2.html) |
| 20 | MetadataNotify, |
| 21 | /// [monitor](http://ircv3.net/specs/core/monitor-3.2.html) |
| 22 | Monitor, |
| 23 | /// [account-tag](http://ircv3.net/specs/extensions/account-tag-3.2.html) |
| 24 | AccountTag, |
| 25 | /// [batch](http://ircv3.net/specs/extensions/batch-3.2.html) |
| 26 | Batch, |
| 27 | /// [cap-notify](http://ircv3.net/specs/extensions/cap-notify-3.2.html) |
| 28 | CapNotify, |
| 29 | /// [chghost](http://ircv3.net/specs/extensions/chghost-3.2.html) |
| 30 | ChgHost, |
| 31 | /// [echo-message](http://ircv3.net/specs/extensions/echo-message-3.2.html) |
| 32 | EchoMessage, |
| 33 | /// [invite-notify](http://ircv3.net/specs/extensions/invite-notify-3.2.html) |
| 34 | InviteNotify, |
| 35 | /// [server-time](http://ircv3.net/specs/extensions/server-time-3.2.html) |
| 36 | ServerTime, |
| 37 | /// [userhost-in-names](http://ircv3.net/specs/extensions/userhost-in-names-3.2.html) |
| 38 | UserhostInNames, |
| 39 | /// Custom IRCv3 capability extensions |
| 40 | Custom(&'static str), |
| 41 | } |
| 42 | |
| 43 | /// List of IRCv3 capability negotiation versions. |
| 44 | pub enum NegotiationVersion { |
| 45 | /// [IRCv3.1](http://ircv3.net/specs/core/capability-negotiation-3.1.html) |
| 46 | V301, |
| 47 | /// [IRCv3.2](http://ircv3.net/specs/core/capability-negotiation-3.2.html) |
| 48 | V302, |
| 49 | } |
| 50 | |
| 51 | impl AsRef<str> for Capability { |
| 52 | fn as_ref(&self) -> &str { |
| 53 | match *self { |
| 54 | Capability::MultiPrefix => "multi-prefix", |
| 55 | Capability::Sasl => "sasl", |
| 56 | Capability::AccountNotify => "account-notify", |
| 57 | Capability::AwayNotify => "away-notify", |
| 58 | Capability::ExtendedJoin => "extended-join", |
| 59 | Capability::Metadata => "metadata", |
| 60 | Capability::MetadataNotify => "metadata-notify", |
| 61 | Capability::Monitor => "monitor", |
| 62 | Capability::AccountTag => "account-tag", |
| 63 | Capability::Batch => "batch", |
| 64 | Capability::CapNotify => "cap-notify", |
| 65 | Capability::ChgHost => "chghost", |
| 66 | Capability::EchoMessage => "echo-message", |
| 67 | Capability::InviteNotify => "invite-notify", |
| 68 | Capability::ServerTime => "server-time", |
| 69 | Capability::UserhostInNames => "userhost-in-names", |
| 70 | Capability::Custom(s) => s, |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | #[cfg(test)] |
| 76 | mod test { |
| 77 | use super::Capability::*; |
| 78 | |
| 79 | #[test] |
| 80 | fn to_str() { |
| 81 | assert_eq!(MultiPrefix.as_ref(), "multi-prefix"); |
| 82 | assert_eq!(Sasl.as_ref(), "sasl"); |
| 83 | assert_eq!(AccountNotify.as_ref(), "account-notify"); |
| 84 | assert_eq!(AwayNotify.as_ref(), "away-notify"); |
| 85 | assert_eq!(ExtendedJoin.as_ref(), "extended-join"); |
| 86 | assert_eq!(Metadata.as_ref(), "metadata"); |
| 87 | assert_eq!(MetadataNotify.as_ref(), "metadata-notify"); |
| 88 | assert_eq!(Monitor.as_ref(), "monitor"); |
| 89 | assert_eq!(AccountTag.as_ref(), "account-tag"); |
| 90 | assert_eq!(Batch.as_ref(), "batch"); |
| 91 | assert_eq!(CapNotify.as_ref(), "cap-notify"); |
| 92 | assert_eq!(ChgHost.as_ref(), "chghost"); |
| 93 | assert_eq!(EchoMessage.as_ref(), "echo-message"); |
| 94 | assert_eq!(InviteNotify.as_ref(), "invite-notify"); |
| 95 | assert_eq!(ServerTime.as_ref(), "server-time"); |
| 96 | assert_eq!(UserhostInNames.as_ref(), "userhost-in-names"); |
| 97 | assert_eq!(Custom("example").as_ref(), "example"); |
| 98 | } |
| 99 | } |