pub enum Source {
File {
filename: Option<PathBuf>,
location: PathBuf,
},
Url {
filename: Option<PathBuf>,
url: Url,
},
}
Expand description
Represents the location that a source file should be retrieved from
It can be either a local file (next to the PKGBUILD) or a URL.
Variants§
File
A local file source.
The location must be a pure file name, without any path components (/
).
Hence, the file must be located directly next to the PKGBUILD.
Url
A URL source.
Implementations§
Trait Implementations§
source§impl FromStr for Source
impl FromStr for Source
source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parses a Source
from string.
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 in the following cases:
- The destination file name or url/source file name are malformed.
- The source file name is an absolute path.
§Examples
use std::path::Path;
use std::str::FromStr;
use alpm_types::Source;
use url::Url;
let source = Source::from_str("foopkg-1.2.3.tar.gz::https://example.com/download").unwrap();
assert_eq!(source.filename().unwrap(), Path::new("foopkg-1.2.3.tar.gz"));
let Source::Url { url, .. } = source else {
panic!()
};
assert_eq!(url.host_str(), Some("example.com"));
let source = Source::from_str("renamed-source.tar.gz::test.tar.gz").unwrap();
assert_eq!(
source.filename().unwrap(),
Path::new("renamed-source.tar.gz")
);
let Source::File { location, .. } = source else {
panic!()
};
assert_eq!(location, Path::new("test.tar.gz"));
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)