1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/// Descriptor for a (username, unique discrimnator) pair.
///
/// OWAPI uses the pair formatted as `"uname-UD"` for API access.
pub trait BNetUser: Sized {
    /// Convert `self` into `"uname-UD"`.
    fn identifier(self) -> String;
}

impl<'a> BNetUser for &'a str {
    fn identifier(self) -> String {
        self.to_string()
    }
}

impl BNetUser for String {
    fn identifier(self) -> String {
        self
    }
}

impl<'a> BNetUser for &'a String {
    fn identifier(self) -> String {
        self.clone()
    }
}

impl<'a> BNetUser for (&'a str, u32) {
    fn identifier(self) -> String {
        format!("{}-{}", self.0, self.1)
    }
}

impl BNetUser for (String, u32) {
    fn identifier(self) -> String {
        format!("{}-{}", self.0, self.1)
    }
}

impl<'a> BNetUser for (&'a String, u32) {
    fn identifier(self) -> String {
        format!("{}-{}", self.0, self.1)
    }
}