pub struct RegistryIndex { /* private fields */ }Expand description
A validated, sparse+-prefix-stripped sparse-index URL: https scheme, no userinfo, and
(for a WorkspaceDeclared candidate) a host the live
deps_core::net_policy::RegistryAccessPolicy allows.
Validated at construction so an invalid or unsafe URL (http://, a scheme other than
sparse+https, a user:pass@ component, or a workspace-declared host the policy blocks)
can never reach a network call — this is SSRF-adjacent input, since a workspace file
controls a network destination (spec NFR-002, plan-1b §1.1-§1.2).
Implementations§
Source§impl RegistryIndex
impl RegistryIndex
Sourcepub fn new(
raw: &str,
trust: IndexTrust,
policy: &RegistryAccessPolicy,
) -> Result<Self, RegistryIndexError>
pub fn new( raw: &str, trust: IndexTrust, policy: &RegistryAccessPolicy, ) -> Result<Self, RegistryIndexError>
Validates and wraps raw — a registry-index manifest value, a
.cargo/config.toml [registries.<name>].index value, or a [source.<name>] registry value, either optionally prefixed with sparse+.
trust states whose input raw is; for IndexTrust::WorkspaceDeclared, policy’s
current deps_core::net_policy::WorkspaceRegistryAccess setting is consulted — a
IndexTrust::Trusted candidate is never policy-checked at all, since it is the
user’s own $CARGO_HOME configuration, not something a cloned repository controls.
§Errors
Returns RegistryIndexError if raw does not parse as a URL, is not https,
carries a userinfo component, or (for a WorkspaceDeclared candidate) resolves to a
host class the current policy blocks.
§Examples
use deps_cargo::config::{IndexTrust, RegistryIndex};
use deps_core::net_policy::RegistryAccessPolicy;
let policy = RegistryAccessPolicy::default();
assert!(
RegistryIndex::new("sparse+https://index.mycorp.dev", IndexTrust::Trusted, &policy)
.is_ok()
);
assert!(
RegistryIndex::new("http://index.mycorp.dev", IndexTrust::Trusted, &policy).is_err()
);
assert!(
RegistryIndex::new(
"https://user:pass@index.mycorp.dev",
IndexTrust::Trusted,
&policy
)
.is_err()
);Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
The validated URL as a string, with no trailing slash guarantee either way (callers
splicing a path onto this must trim as needed — see sparse::sparse_index_url).
Sourcepub const fn trust(&self) -> IndexTrust
pub const fn trust(&self) -> IndexTrust
The IndexTrust tier this index was validated under.
Trait Implementations§
Source§impl Clone for RegistryIndex
impl Clone for RegistryIndex
Source§fn clone(&self) -> RegistryIndex
fn clone(&self) -> RegistryIndex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RegistryIndex
impl Debug for RegistryIndex
Source§impl Display for RegistryIndex
impl Display for RegistryIndex
impl Eq for RegistryIndex
Source§impl Hash for RegistryIndex
impl Hash for RegistryIndex
Source§impl PartialEq for RegistryIndex
impl PartialEq for RegistryIndex
Source§fn eq(&self, other: &RegistryIndex) -> bool
fn eq(&self, other: &RegistryIndex) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for RegistryIndex
Auto Trait Implementations§
impl Freeze for RegistryIndex
impl RefUnwindSafe for RegistryIndex
impl Send for RegistryIndex
impl Sync for RegistryIndex
impl Unpin for RegistryIndex
impl UnsafeUnpin for RegistryIndex
impl UnwindSafe for RegistryIndex
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,
§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
§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.