Struct alpm_types::Source
source · pub struct Source {
pub filename: Option<Filename>,
pub location: SourceLocation,
}
Expand description
Represents a source directive. Consists of an optional local filename and a SourceLocation
to get the file from.
Fields§
§filename: Option<Filename>
§location: SourceLocation
Implementations§
source§impl Source
impl Source
sourcepub fn new(s: &str) -> Result<Self, Error>
pub fn new(s: &str) -> Result<Self, Error>
Parses a source directive. It is either a filename (in the same directory as the PKGBUILD)
or a url, optionally prefixed by a destination file name (separated by ::
).
§Errors
This function returns an error if the destination file name or url/source file name are malformed.
§Examples
use alpm_types::{Source, SourceLocation};
use url::Url;
let source = Source::new("foopkg-1.2.3.tar.gz::https://example.com/download").unwrap();
assert_eq!(source.filename.unwrap().as_str(), "foopkg-1.2.3.tar.gz");
let SourceLocation::Url(url) = source.location else { panic!() };
assert_eq!(url.host_str(), Some("example.com"));
Trait Implementations§
source§impl PartialEq for Source
impl PartialEq for Source
impl Eq for Source
impl StructuralPartialEq for Source
Auto Trait Implementations§
impl Freeze for Source
impl RefUnwindSafe for Source
impl Send for Source
impl Sync for Source
impl Unpin for Source
impl UnwindSafe for Source
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more