Skip to main content

SourceRef

Struct SourceRef 

Source
pub struct SourceRef { /* private fields */ }
Expand description

A source: the repository a git URL or a local path names. Never holds credentials (SourceRef::fetch_url takes them from the URL given).

Implementations§

Source§

impl SourceRef

Source

pub fn from_git_url(url: &str) -> Result<Self, CoreError>

The source a git URL names: https://, http://, ssh://, git://, user@host:path, file:// or an absolute local path (a local repository). invalid_value for anything else, and for a URL git could read as another host or path than its key names.

Source

pub fn from_key_or_url(text: &str) -> Result<Self, CoreError>

The repository a source key (host/path, http://host/path, file:///path) or a git URL names.

Source

pub fn canonical_key(text: &str) -> Result<(String, SourceScope), CoreError>

The canonical form of a source key or git URL, with the scope its shape stands for: host/path (or a URL) a repository, host/owner/* an owner, host/* a host; keys of plain http:// and git:// sources keep that prefix. sources.toml keys and the CLI’s key arguments go through it (github.com/Acme/* is github.com/acme/*, github.com./x/y.git is github.com/x/y).

Source

pub fn redact_userinfo(text: &str) -> String

text with the userinfo of every URL in it replaced by ***, for messages: a URL can carry a token (https://user:token@host/...).

Source

pub fn from_local_path(path: &Path) -> Result<Self, CoreError>

A local folder or repository (absolute path).

Source

pub fn whole_host(url: &str) -> Result<Self, CoreError>

The host of an https:// (or http://) endpoint as a whole: the key host/* (http://host/* without encryption), trusted or blocked only at the host scope. A registry entry’s remote server is gated on it (#26): every path of that host is one operator’s.

Source

pub fn key(&self) -> &str

The repository key.

Source

pub fn url(&self) -> &str

The canonical URL without credentials (an SSH user stays); a local source’s file:/// key.

Source

pub fn fetch_url(&self, given: &str) -> String

The URL git must fetch the source from: the canonical URL rebuilt from the parsed parts, with the userinfo of given (the URL as the user gave it) when given names this same source. Never show it or store it: it can carry a token. A local source: given when it names this source, else its file:/// URL.

Source

pub fn is_insecure(&self) -> bool

Fetched over a connection without encryption (http://, git://): anyone on the network path can change what arrives.

Source

pub fn is_local(&self) -> bool

Source

pub fn local_path(&self) -> Option<PathBuf>

A local source’s path, for showing it under its placeholder root.

Source

pub fn host(&self) -> Option<&str>

Source

pub fn owner(&self) -> Option<&str>

Source

pub fn scope_key(&self, scope: SourceScope) -> Option<String>

The key of scope (host/owner/*, host/*, with the http:// or git:// prefix of an insecure source); None when the source has no such scope (a local source, a repository without an owner segment).

Source

pub fn matching_keys(&self) -> Vec<String>

Every key whose trust applies, most specific first.

Source

pub fn block_keys(&self) -> Vec<String>

Every key whose block applies, most specific first: the Self::matching_keys, then for an insecure source the keys of the same source over an encrypted transport (a block covers every transport, a trust only its own).

Source

pub fn scopes(&self) -> Vec<SourceScope>

The scopes “always trust” offers, narrowest first: a host only when it is not an AGGREGATOR_HOSTS host.

Source

pub fn is_official(&self) -> bool

An OFFICIAL_OWNERS repository, fetched over an encrypted transport.

Trait Implementations§

Source§

impl Clone for SourceRef

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SourceRef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SourceRef

Source§

impl Hash for SourceRef

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for SourceRef

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SourceRef

Auto Trait Implementations§

§

impl Forget for SourceRef

§

impl Freeze for SourceRef
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for SourceRef

§

impl RefUnwindSafe for SourceRef

§

impl Send for SourceRef
where RawVecInner: Send,

§

impl Sync for SourceRef
where RawVecInner: Sync,

§

impl Unpin for SourceRef
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for SourceRef

§

impl UnwindSafe for SourceRef
where RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more