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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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);