pub enum Source {
File {
filename: Option<PathBuf>,
location: PathBuf,
},
SourceUrl {
filename: Option<PathBuf>,
source_url: SourceUrl,
},
}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.
Fields
SourceUrl
A URL source.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Source
impl<'de> Deserialize<'de> for Source
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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>
Creates a Source from a string slice.
It is either a filename (in the same directory as the PKGBUILD)
or a url, optionally prefixed by a destination file name (separated by ::).
Delegates to Source::parser_until.
§Errors
Returns an error if Source::parser_until fails.
§Examples
use std::{path::Path, str::FromStr};
use alpm_types::Source;
use url::Url;
// Parse from a string that represents a remote file link.
let source = Source::from_str("foopkg-1.2.3.tar.gz::https://example.com/download")?;
let Source::SourceUrl {
source_url,
filename,
} = source
else {
panic!()
};
assert_eq!(filename.unwrap(), Path::new("foopkg-1.2.3.tar.gz"));
assert_eq!(source_url.url.inner().host_str(), Some("example.com"));
assert_eq!(source_url.to_string(), "https://example.com/download");
// Parse from a string that represents a local file.
let source = Source::from_str("renamed-source.tar.gz::test.tar.gz")?;
let Source::File { location, filename } = source else {
panic!()
};
assert_eq!(location, Path::new("test.tar.gz"));
assert_eq!(filename.unwrap(), Path::new("renamed-source.tar.gz"));
Source§impl ParserUntil for Source
For Source, we only define a ParserUntil trait and not the AlpmParser trait, as we
don’t provide the Url type parser ourselves. Hence, the indicator for its supposed
“end” must be provided by the caller of the parser.
impl ParserUntil for Source
For Source, we only define a ParserUntil trait and not the AlpmParser trait, as we
don’t provide the Url type parser ourselves. Hence, the indicator for its supposed
“end” must be provided by the caller of the parser.
Source§fn parser_until<'a, P>(
delimiter: P,
) -> impl Parser<&'a str, Self, ErrMode<ContextError>>
fn parser_until<'a, P>( delimiter: P, ) -> impl Parser<&'a str, Self, ErrMode<ContextError>>
Source§fn parser_until_eof(input: &mut &str) -> Result<Self, ErrMode<ContextError>>
fn parser_until_eof(input: &mut &str) -> Result<Self, ErrMode<ContextError>>
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 UnsafeUnpin for Source
impl UnwindSafe for Source
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<U> ParserUntilInclusive for Uwhere
U: ParserUntil,
impl<U> ParserUntilInclusive for Uwhere
U: ParserUntil,
Source§fn parser_until_inclusive<'a, P>(
delimiter: P,
) -> impl Parser<&'a str, U, ErrMode<ContextError>>
fn parser_until_inclusive<'a, P>( delimiter: P, ) -> impl Parser<&'a str, U, ErrMode<ContextError>>
Returns a [Parser] that parses the whole input and consumes the given delimiter parser.
Delegates to ParserUntil::parser_until and consumes the delimiter.