license 0.3.0

A license library.
Documentation
use Kind;
use conditions::Conditions;
use limitations::Limitations;
use permissions::Permissions;

/// Base functionality for all licenses.
pub trait License {
    /// The name of the license.
    ///
    /// Corresponds to the *Full name* column from https://spdx.org/licenses/.
    fn name(&self) -> &str;

    /// The identifier of the license.
    ///
    /// Corresponds to the *Identifier* column from https://spdx.org/licenses/.
    fn id(&self) -> &str;

    /// Says if the license is OSI approved.
    ///
    /// Corresponds to the *OSI Approved?* column from https://spdx.org/licenses/.
    fn is_osi_approved(&self) -> bool;

    /// The license text.
    fn text(&self) -> &str;

    /// The permissions of the license.
    fn permissions(&self) -> Permissions;

    /// The conditions of the license.
    fn conditions(&self) -> Conditions;

    /// The limitations of the license.
    fn limitations(&self) -> Limitations;

    /// The homepage of the license.
    #[inline]
    fn homepage(&self) -> Option<&str> {
        None
    }
}

impl From<Kind> for Box<License> {
    #[inline]
    fn from(kind: Kind) -> Self {
        match kind {
            Kind::Agpl3(agpl3) => Box::new(agpl3),
            Kind::Apache2(apache2) => Box::new(apache2),
            Kind::Cc01(cc01) => Box::new(cc01),
            Kind::Gpl3(gpl3) => Box::new(gpl3),
            Kind::Lgpl3(lgpl3) => Box::new(lgpl3),
            Kind::Mit(mit) => Box::new(mit),
            Kind::Mpl2(mpl2) => Box::new(mpl2),
            Kind::Unlicense(unlicense) => Box::new(unlicense),
        }
    }
}

impl_license!(License);