#[non_exhaustive]pub struct NetworkConfig {
pub offline: bool,
}Expand description
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.offline: boolWhen true, blocks every new outbound registry/OSV/GitHub-tags request
(deps_core::cache::HttpCache’s 4 send sites) instead of making it, serving
already-cached data where available and returning deps_core::DepsError::Offline
otherwise. Also forces cache.enabled semantics to true for the duration (see
CacheConfig::enabled’s doc comment), so a warm entry keeps serving through an
online→offline transition even if caching was explicitly disabled.
HttpCache::set_offline is a bare atomic store: a request already past its
ensure_online check and awaiting a response completes normally, and toggling
this flag never cancels in-flight requests.
Implementations§
Source§impl NetworkConfig
impl NetworkConfig
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Builds the default configuration (mirrors Self::default).
Needed because Self is #[non_exhaustive]: a struct literal only works inside
deps-core, so every other crate must chain the with_* setters onto this
constructor instead.
§Examples
use deps_core::policy_config::NetworkConfig;
let config = NetworkConfig::new();
assert!(!config.offline);Sourcepub const fn with_offline(self, offline: bool) -> Self
pub const fn with_offline(self, offline: bool) -> Self
Overrides Self::offline. See Self::new.
Sourcepub fn mode(&self) -> NetworkMode
pub fn mode(&self) -> NetworkMode
Converts Self::offline into the typed crate::NetworkMode every
network-reachability call site reads instead of the raw config flag.
§Examples
use deps_core::NetworkMode;
use deps_core::policy_config::NetworkConfig;
let config = NetworkConfig::new().with_offline(true);
assert_eq!(config.mode(), NetworkMode::Offline);