aatxe / irc

the irc crate – usable, async IRC for Rust
Mozilla Public License 2.0
531 stars 97 forks source link

Change `Capability` to trait `AsRef<str>` #25

Closed kgv closed 9 years ago

kgv commented 9 years ago
pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
...
    /// Sends an IRCv3 capabilities request for the specified extensions.
    fn send_cap_req(&self, extensions: &[Capability]) -> Result<()> where Self: Sized {
...

Propose: Change Capability to trait AsRef<str>.

Because some servers use custom capabilities (for example)

aatxe commented 9 years ago

Would it suffice to add a Custom capability? My thinking is that it's fitting since some (maybe most?) capabilities will actually require some sort of tangible support beyond just sending a request for it. So, it might then make sense to still keep the enumeration around. Your alternative is also perfectly reasonable. It's not dissimilar to some of the concerns with the current Command design and potential redesign options in #16. Do you think it'd be preferred ergonomically to just use strings for requesting capabilities?

kgv commented 9 years ago

I think that keeping the enumeration and adding Custom variant will be more ergonomically.

aatxe commented 9 years ago

This was implemented in a5306f83918a4a4b17826844e5fac7d4fe6a9498.