pub struct RegistryAccessPolicy(/* private fields */);Expand description
Live-updatable, Arc-shareable handle to the current WorkspaceRegistryAccess setting.
Backed by an AtomicU8 rather than a lock: the manifest parse path that reads this is a
synchronous call inside an async fn, where a tokio::sync::RwLock cannot be awaited and a
std::sync::RwLock would be unnecessary ceremony for one small Copy enum. initialize
and workspace/didChangeConfiguration call Self::set; every manifest parse calls
Self::get.
§Examples
use deps_core::net_policy::{RegistryAccessPolicy, WorkspaceRegistryAccess};
let policy = RegistryAccessPolicy::new(WorkspaceRegistryAccess::Off);
assert_eq!(policy.get(), WorkspaceRegistryAccess::Off);
policy.set(WorkspaceRegistryAccess::PublicOnly);
assert_eq!(policy.get(), WorkspaceRegistryAccess::PublicOnly);Implementations§
Source§impl RegistryAccessPolicy
impl RegistryAccessPolicy
Sourcepub fn new(initial: WorkspaceRegistryAccess) -> Self
pub fn new(initial: WorkspaceRegistryAccess) -> Self
Creates a handle initialized to initial.
Sourcepub fn get(&self) -> WorkspaceRegistryAccess
pub fn get(&self) -> WorkspaceRegistryAccess
The current policy.
Sourcepub fn set(&self, value: WorkspaceRegistryAccess)
pub fn set(&self, value: WorkspaceRegistryAccess)
Updates the current policy, effective for every parse after this call returns.
A tightening (e.g. All -> PublicOnly/Off) only gates future parses: it does not
purge state a looser policy already produced, such as deps-cargo’s
CargoRegistry::alternates map — an already-registered alternate-registry client for a
now-blocked host stays reachable until its owning document is next re-parsed (today,
workspace/didChangeConfiguration does not trigger a re-parse of open documents). This
is pre-existing behavior, unrelated to this type’s own storage, and unchanged by it.
§Warning
Calling this directly on a handle already bound to an
crate::cache::HttpCache (via crate::cache::HttpCache::with_policy) updates this
value but does not rebuild that cache’s workspace transport, leaving its AddrGuard and
cache-key namespace on the stale policy. For a bound cache, always mutate through
crate::cache::HttpCache::set_registry_policy instead, which updates this handle and
rebuilds the transport together.