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
impl SourceRef
Sourcepub fn from_git_url(url: &str) -> Result<Self, CoreError>
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.
Sourcepub fn from_key_or_url(text: &str) -> Result<Self, CoreError>
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.
Sourcepub fn canonical_key(text: &str) -> Result<(String, SourceScope), CoreError>
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).
Sourcepub fn redact_userinfo(text: &str) -> String
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/...).
Sourcepub fn from_local_path(path: &Path) -> Result<Self, CoreError>
pub fn from_local_path(path: &Path) -> Result<Self, CoreError>
A local folder or repository (absolute path).
Sourcepub fn whole_host(url: &str) -> Result<Self, CoreError>
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.
Sourcepub fn url(&self) -> &str
pub fn url(&self) -> &str
The canonical URL without credentials (an SSH user stays); a local
source’s file:/// key.
Sourcepub fn fetch_url(&self, given: &str) -> String
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.
Sourcepub fn is_insecure(&self) -> bool
pub fn is_insecure(&self) -> bool
Fetched over a connection without encryption (http://, git://):
anyone on the network path can change what arrives.
pub fn is_local(&self) -> bool
Sourcepub fn local_path(&self) -> Option<PathBuf>
pub fn local_path(&self) -> Option<PathBuf>
A local source’s path, for showing it under its placeholder root.
pub fn host(&self) -> Option<&str>
pub fn owner(&self) -> Option<&str>
Sourcepub fn scope_key(&self, scope: SourceScope) -> Option<String>
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).
Sourcepub fn matching_keys(&self) -> Vec<String>
pub fn matching_keys(&self) -> Vec<String>
Every key whose trust applies, most specific first.
Sourcepub fn block_keys(&self) -> Vec<String>
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).
Sourcepub fn scopes(&self) -> Vec<SourceScope>
pub fn scopes(&self) -> Vec<SourceScope>
The scopes “always trust” offers, narrowest first: a host only
when it is not an AGGREGATOR_HOSTS host.
Sourcepub fn is_official(&self) -> bool
pub fn is_official(&self) -> bool
An OFFICIAL_OWNERS repository, fetched over an encrypted
transport.
Trait Implementations§
impl Eq for SourceRef
impl StructuralPartialEq for SourceRef
Auto Trait Implementations§
impl Forget for SourceRef
impl Freeze for SourceRef
impl Move for SourceRef
impl RefUnwindSafe for SourceRef
impl Send for SourceRefwhere
RawVecInner: Send,
impl Sync for SourceRefwhere
RawVecInner: Sync,
impl Unpin for SourceRef
impl UnsafeUnpin for SourceRef
impl UnwindSafe for SourceRefwhere
RawVecInner: UnwindSafe,
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.