Struct cc_license::License
source · pub struct License { /* private fields */ }
Implementations§
source§impl License
impl License
sourcepub fn from_url(url: &str) -> Result<Self, ParseError>
pub fn from_url(url: &str) -> Result<Self, ParseError>
Parse a Creative Commons license from a URL
Example
use cc_license::License;
let license = License::from_url("https://creativecommons.org/licenses/by-nc-sa/4.0/")?;
assert_eq!(license.to_string(), "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International license (CC BY-NC-SA 4.0).".to_string());
sourcepub fn rights(&self) -> String
pub fn rights(&self) -> String
Obtain the abbreviated rights string from a license
Example
use cc_license::License;
let license = License::from_url("https://creativecommons.org/licenses/by/4.0/")?;
assert_eq!(license.rights(), "CC BY".to_string());
sourcepub fn rights_full(&self) -> String
pub fn rights_full(&self) -> String
Obtain the rights string from a license
Example
use cc_license::License;
let license = License::from_url("https://creativecommons.org/licenses/by-nc-sa/4.0/")?;
assert_eq!(license.rights_full(), "Attribution-NonCommercial-ShareAlike".to_string());