Enum guppy::graph::ExternalSource
source · #[non_exhaustive]pub enum ExternalSource<'g> {
Registry(&'g str),
Git {
repository: &'g str,
req: GitReq<'g>,
resolved: &'g str,
},
}
Expand description
More information about an external source.
This provides information about whether an external dependency is a Git dependency or fetched from a registry.
Returned by PackageSource::parse_external
.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Registry(&'g str)
This is a registry source, e.g. "registry+https://github.com/rust-lang/crates.io-index"
.
The associated data is the part of the string after the initial "registry+"
.
§Examples
use guppy::graph::ExternalSource;
let source = "registry+https://github.com/rust-lang/crates.io-index";
let parsed = ExternalSource::new(source).expect("this source is understood by guppy");
assert_eq!(
parsed,
ExternalSource::Registry("https://github.com/rust-lang/crates.io-index"),
);
Git
This is a Git source.
An example of a Git source string is "git+https://github.com/rust-lang/cargo.git?branch=main#0227f048fcb7c798026ede6cc20c92befc84c3a4"
.
In this case, the Cargo.toml
would have contained:
cargo = { git = "https://github.com/rust-lang/cargo.git", branch = "main" }
and the Cargo.lock
would have contained:
[[package]]
name = "cargo"
version = "0.46.0"
source = "git+https://github.com/rust-lang/cargo.git?branch=main#0227f048fcb7c798026ede6cc20c92befc84c3a4
dependencies = [ ... ]
For more, see Specifying dependencies from git
repositories
in the Cargo book.
§Examples
use guppy::graph::{ExternalSource, GitReq};
// A branch source.
let source = "git+https://github.com/rust-lang/cargo.git?branch=main#0227f048fcb7c798026ede6cc20c92befc84c3a4";
let parsed = ExternalSource::new(source).expect("this source is understood by guppy");
assert_eq!(
parsed,
ExternalSource::Git {
repository: "https://github.com/rust-lang/cargo.git",
req: GitReq::Branch("main"),
resolved: "0227f048fcb7c798026ede6cc20c92befc84c3a4",
}
);
// A tag source.
let source = "git+https://github.com/rust-lang/cargo.git?tag=v0.46.0#0227f048fcb7c798026ede6cc20c92befc84c3a4";
let parsed = ExternalSource::new(source).expect("this source is understood by guppy");
assert_eq!(
parsed,
ExternalSource::Git {
repository: "https://github.com/rust-lang/cargo.git",
req: GitReq::Tag("v0.46.0"),
resolved: "0227f048fcb7c798026ede6cc20c92befc84c3a4",
}
);
// A revision source.
let source = "git+https://github.com/rust-lang/cargo.git?rev=0227f048fcb7c798026ede6cc20c92befc84c3a4#0227f048fcb7c798026ede6cc20c92befc84c3a4";
let parsed = ExternalSource::new(source).expect("this source is understood by guppy");
assert_eq!(
parsed,
ExternalSource::Git {
repository: "https://github.com/rust-lang/cargo.git",
req: GitReq::Rev("0227f048fcb7c798026ede6cc20c92befc84c3a4"),
resolved: "0227f048fcb7c798026ede6cc20c92befc84c3a4",
}
);
// A default source.
let source = "git+https://github.com/gyscos/zstd-rs.git#bc874a57298bdb500cdb5aeac5f23878b6480d0b";
let parsed = ExternalSource::new(source).expect("this source is understood by guppy");
assert_eq!(
parsed,
ExternalSource::Git {
repository: "https://github.com/gyscos/zstd-rs.git",
req: GitReq::Default,
resolved: "bc874a57298bdb500cdb5aeac5f23878b6480d0b",
}
);
Fields
repository: &'g str
The repository for this Git source. For the above example, this would be
"https://github.com/rust-lang/cargo.git"
.
Implementations§
source§impl<'g> ExternalSource<'g>
impl<'g> ExternalSource<'g>
sourcepub const REGISTRY_PLUS: &'static str = "registry+"
pub const REGISTRY_PLUS: &'static str = "registry+"
The string "registry+"
.
Used for matching with the Registry
variant.
sourcepub const GIT_PLUS: &'static str = "git+"
pub const GIT_PLUS: &'static str = "git+"
The string "git+"
.
Used for matching with the Git
variant.
sourcepub const BRANCH_EQ: &'static str = "?branch="
pub const BRANCH_EQ: &'static str = "?branch="
The string "?branch="
.
Used for matching with the Git
variant.
sourcepub const TAG_EQ: &'static str = "?tag="
pub const TAG_EQ: &'static str = "?tag="
The string "?tag="
.
Used for matching with the Git
variant.
sourcepub const REV_EQ: &'static str = "?rev="
pub const REV_EQ: &'static str = "?rev="
The string "?rev="
.
Used for matching with the Git
variant.
sourcepub const CRATES_IO_URL: &'static str = "https://github.com/rust-lang/crates.io-index"
pub const CRATES_IO_URL: &'static str = "https://github.com/rust-lang/crates.io-index"
The URL for the crates.io
registry.
This lacks the leading "registry+
“ that’s part of the PackageSource
.
Trait Implementations§
source§impl<'g> Clone for ExternalSource<'g>
impl<'g> Clone for ExternalSource<'g>
source§fn clone(&self) -> ExternalSource<'g>
fn clone(&self) -> ExternalSource<'g>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'g> Debug for ExternalSource<'g>
impl<'g> Debug for ExternalSource<'g>
source§impl<'g> Display for ExternalSource<'g>
impl<'g> Display for ExternalSource<'g>
The Display
implementation for ExternalSource
returns the string it was constructed from.
§Examples
use guppy::graph::{ExternalSource, GitReq};
let source = ExternalSource::Git {
repository: "https://github.com/rust-lang/cargo.git",
req: GitReq::Branch("main"),
resolved: "0227f048fcb7c798026ede6cc20c92befc84c3a4",
};
assert_eq!(
format!("{}", source),
"git+https://github.com/rust-lang/cargo.git?branch=main#0227f048fcb7c798026ede6cc20c92befc84c3a4",
);
source§impl<'g> Hash for ExternalSource<'g>
impl<'g> Hash for ExternalSource<'g>
source§impl<'g> PartialEq for ExternalSource<'g>
impl<'g> PartialEq for ExternalSource<'g>
impl<'g> Copy for ExternalSource<'g>
impl<'g> Eq for ExternalSource<'g>
impl<'g> StructuralPartialEq for ExternalSource<'g>
Auto Trait Implementations§
impl<'g> Freeze for ExternalSource<'g>
impl<'g> RefUnwindSafe for ExternalSource<'g>
impl<'g> Send for ExternalSource<'g>
impl<'g> Sync for ExternalSource<'g>
impl<'g> Unpin for ExternalSource<'g>
impl<'g> UnwindSafe for ExternalSource<'g>
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
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)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more