pub enum PolicyGate<'a> {
Skip,
Enforce(&'a RegistryAccessPolicy),
}Expand description
Whether validate_index_url must check a candidate’s host against a live
RegistryAccessPolicy.
An explicit enum, not Option/bool: a trusted-provenance candidate (e.g. deps-cargo’s
$CARGO_HOME-sourced IndexTrust::Trusted) skipping the policy check entirely is a
security-relevant decision each call site must make visibly, not something that can be
expressed by a None a reader might mistake for “no policy configured yet”.
§Examples
use deps_core::net_policy::{PolicyGate, RegistryAccessPolicy, WorkspaceRegistryAccess, validate_index_url};
let policy = RegistryAccessPolicy::new(WorkspaceRegistryAccess::Off);
assert!(
validate_index_url("https://index.mycorp.dev", "https://index.mycorp.dev", "cargo", PolicyGate::Skip)
.is_ok()
);
assert!(
validate_index_url(
"https://index.mycorp.dev",
"https://index.mycorp.dev",
"cargo",
PolicyGate::Enforce(&policy)
)
.is_err()
);Variants§
Skip
Skip the policy check entirely — the candidate’s provenance is already trusted (e.g.
the user’s own $CARGO_HOME configuration), not something a cloned repository
controls.
Enforce(&'a RegistryAccessPolicy)
Check the candidate’s host against policy — the candidate’s provenance is a
workspace file, which an opened repository fully controls.
Trait Implementations§
Source§impl<'a> Clone for PolicyGate<'a>
impl<'a> Clone for PolicyGate<'a>
Source§fn clone(&self) -> PolicyGate<'a>
fn clone(&self) -> PolicyGate<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<'a> Copy for PolicyGate<'a>
Auto Trait Implementations§
impl<'a> Freeze for PolicyGate<'a>
impl<'a> RefUnwindSafe for PolicyGate<'a>
impl<'a> Send for PolicyGate<'a>
impl<'a> Sync for PolicyGate<'a>
impl<'a> Unpin for PolicyGate<'a>
impl<'a> UnsafeUnpin for PolicyGate<'a>
impl<'a> UnwindSafe for PolicyGate<'a>
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
Mutably borrows from an owned value. Read more