Struct debian_copyright::Copyright

source ·
pub struct Copyright(/* private fields */);

Implementations§

source

pub fn new() -> Self

source

pub fn empty() -> Self

source

pub fn header(&self) -> Option<Header>

source

pub fn iter_files(&self) -> impl Iterator<Item = FilesParagraph>

source

pub fn iter_licenses(&self) -> impl Iterator<Item = LicenseParagraph>

source

pub fn find_files(&self, filename: &Path) -> Option<FilesParagraph>

Returns the Files paragraph for the given filename.

Consistent with the specification, this returns the last paragraph that matches (which should be the most specific)

source

pub fn find_license_by_name(&self, name: &str) -> Option<License>

source

pub fn find_license_for_file(&self, filename: &Path) -> Option<License>

Returns the license for the given file.

Examples found in repository?
examples/license-for-file.rs (line 26)
24
25
26
27
28
pub fn main() {
    let c = TEXT.parse::<Copyright>().unwrap();
    let license = c.find_license_for_file(Path::new("debian/foo")).unwrap();
    println!("{}", license.name().unwrap());
}
source

pub fn from_str_relaxed(s: &str) -> Result<(Self, Vec<String>), Error>

source

pub fn from_file_relaxed<P: AsRef<Path>>( path: P, ) -> Result<(Self, Vec<String>), Error>

source

pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Trait Implementations§

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

type Err = Error

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.