Enum guppy::graph::ExternalSource [−][src]
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)
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"), );
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 of Git
repository: &'g str
The repository for this Git source. For the above example, this would be
"https://github.com/rust-lang/cargo.git"
.
req: GitReq<'g>
The revision requested in Cargo.toml
. This may be a tag, a branch or a specific
revision (commit hash).
For the above example, req
would be GitSource::Branch("main")
.
resolved: &'g str
The resolved revision, as specified in Cargo.lock
.
For the above example, resolved_hash
would be "0227f048fcb7c798026ede6cc20c92befc84c3a4"
.
This is always a commit hash, and if req
is GitReq::Rev
then it is expected
to be the same hash. (However, this is not verified by guppy.)
Implementations
impl<'g> ExternalSource<'g>
[src]
pub const REGISTRY_PLUS: &'static str
[src]
The string "registry+"
.
Used for matching with the Registry
variant.
pub const GIT_PLUS: &'static str
[src]
The string "git+"
.
Used for matching with the Git
variant.
pub const BRANCH_EQ: &'static str
[src]
The string "?branch="
.
Used for matching with the Git
variant.
pub const TAG_EQ: &'static str
[src]
The string "?tag="
.
Used for matching with the Git
variant.
pub const REV_EQ: &'static str
[src]
The string "?rev="
.
Used for matching with the Git
variant.
pub fn new(source: &'g str) -> Option<Self>
[src]
Attempts to parse the given string as an external source.
Returns None
if the string could not be recognized as an external source.
Trait Implementations
impl<'g> Clone for ExternalSource<'g>
[src]
fn clone(&self) -> ExternalSource<'g>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'g> Copy for ExternalSource<'g>
[src]
impl<'g> Debug for ExternalSource<'g>
[src]
impl<'g> Display for ExternalSource<'g>
[src]
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", );
impl<'g> Eq for ExternalSource<'g>
[src]
impl<'g> Hash for ExternalSource<'g>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'g> PartialEq<ExternalSource<'g>> for ExternalSource<'g>
[src]
fn eq(&self, other: &ExternalSource<'g>) -> bool
[src]
fn ne(&self, other: &ExternalSource<'g>) -> bool
[src]
impl<'g> StructuralEq for ExternalSource<'g>
[src]
impl<'g> StructuralPartialEq for ExternalSource<'g>
[src]
Auto Trait Implementations
impl<'g> RefUnwindSafe for ExternalSource<'g>
[src]
impl<'g> Send for ExternalSource<'g>
[src]
impl<'g> Sync for ExternalSource<'g>
[src]
impl<'g> Unpin for ExternalSource<'g>
[src]
impl<'g> UnwindSafe for ExternalSource<'g>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<'a, T> DefaultFeatures<'a> for T where
T: 'a + Clone + Send + Sync,
[src]
T: 'a + Clone + Send + Sync,
pub fn clone_boxed(&self) -> Box<dyn DefaultFeatures<'a> + 'a, Global>
[src]
pub fn self_address_mut(&mut self) -> *mut ()
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<'a, T> NonSyncFeatures<'a> for T where
T: 'a + Clone,
[src]
T: 'a + Clone,
pub fn clone_boxed(&self) -> Box<dyn NonSyncFeatures<'a> + 'a, Global>
[src]
pub fn self_address_mut(&mut self) -> *mut ()
[src]
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> SafeBorrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_replacement(ptr: &T) -> &T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,