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
//! RPM licenses

use std::fmt::{self, Display};

/// License types
// TODO: support AND/OR, enum for license types
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct License(String);

impl License {
    /// Create a new license
    pub(crate) fn new<S: AsRef<str>>(string: S) -> License {
        License(string.as_ref().to_owned())
    }

    /// Get a string representation of this license
    pub fn as_str(&self) -> &str {
        &self.0
    }
}

impl Display for License {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        self.0.fmt(f)
    }
}

impl AsRef<str> for License {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}