pub struct Config {Show 36 fields
home_path: Filesystem,
shell: RefCell<Shell>,
values: LazyCell<HashMap<String, ConfigValue>>,
credential_values: LazyCell<HashMap<String, ConfigValue>>,
cli_config: Option<Vec<String>>,
cwd: PathBuf,
search_stop_path: Option<PathBuf>,
cargo_exe: LazyCell<PathBuf>,
rustdoc: LazyCell<PathBuf>,
extra_verbose: bool,
frozen: bool,
locked: bool,
offline: bool,
jobserver: Option<Client>,
unstable_flags: CliUnstable,
unstable_flags_cli: Option<Vec<String>>,
easy: LazyCell<RefCell<Easy>>,
crates_io_source_id: LazyCell<SourceId>,
cache_rustc_info: bool,
creation_time: Instant,
target_dir: Option<Filesystem>,
env: Env,
updated_sources: LazyCell<RefCell<HashSet<SourceId>>>,
credential_cache: LazyCell<RefCell<HashMap<CanonicalUrl, CredentialCacheValue>>>,
registry_config: LazyCell<RefCell<HashMap<SourceId, Option<RegistryConfig>>>>,
package_cache_lock: RefCell<Option<(Option<FileLock>, usize)>>,
http_config: LazyCell<CargoHttpConfig>,
future_incompat_config: LazyCell<CargoFutureIncompatConfig>,
net_config: LazyCell<CargoNetConfig>,
build_config: LazyCell<CargoBuildConfig>,
target_cfgs: LazyCell<Vec<(String, TargetCfgConfig)>>,
doc_extern_map: LazyCell<RustdocExternMap>,
progress_config: ProgressConfig,
env_config: LazyCell<EnvConfig>,
pub nightly_features_allowed: bool,
pub ws_roots: RefCell<HashMap<PathBuf, WorkspaceRootConfig>>,
}
Expand description
Configuration information for cargo. This is not specific to a build, it is information relating to cargo itself.
Fields§
§home_path: Filesystem
The location of the user’s Cargo home directory. OS-dependent.
shell: RefCell<Shell>
Information about how to write messages to the shell
values: LazyCell<HashMap<String, ConfigValue>>
A collection of configuration options
credential_values: LazyCell<HashMap<String, ConfigValue>>
A collection of configuration options from the credentials file
cli_config: Option<Vec<String>>
CLI config values, passed in via configure
.
cwd: PathBuf
The current working directory of cargo
search_stop_path: Option<PathBuf>
Directory where config file searching should stop (inclusive).
cargo_exe: LazyCell<PathBuf>
The location of the cargo executable (path to current process)
rustdoc: LazyCell<PathBuf>
The location of the rustdoc executable
extra_verbose: bool
Whether we are printing extra verbose messages
frozen: bool
frozen
is the same as locked
, but additionally will not access the
network to determine if the lock file is out-of-date.
locked: bool
locked
is set if we should not update lock files. If the lock file
is missing, or needs to be updated, an error is produced.
offline: bool
offline
is set if we should never access the network, but otherwise
continue operating if possible.
jobserver: Option<Client>
A global static IPC control mechanism (used for managing parallel builds)
unstable_flags: CliUnstable
Cli flags of the form “-Z something” merged with config file values
unstable_flags_cli: Option<Vec<String>>
Cli flags of the form “-Z something”
easy: LazyCell<RefCell<Easy>>
A handle on curl easy mode for http calls
crates_io_source_id: LazyCell<SourceId>
Cache of the SourceId
for crates.io
cache_rustc_info: bool
If false, don’t cache rustc --version --verbose
invocations
creation_time: Instant
Creation time of this config, used to output the total build time
target_dir: Option<Filesystem>
Target Directory via resolved Cli parameter
env: Env
Environment variable snapshot.
updated_sources: LazyCell<RefCell<HashSet<SourceId>>>
Tracks which sources have been updated to avoid multiple updates.
credential_cache: LazyCell<RefCell<HashMap<CanonicalUrl, CredentialCacheValue>>>
Cache of credentials from configuration or credential providers. Maps from url to credential value.
registry_config: LazyCell<RefCell<HashMap<SourceId, Option<RegistryConfig>>>>
Cache of registry config from from the [registries]
table.
package_cache_lock: RefCell<Option<(Option<FileLock>, usize)>>
Lock, if held, of the global package cache along with the number of acquisitions so far.
http_config: LazyCell<CargoHttpConfig>
Cached configuration parsed by Cargo
future_incompat_config: LazyCell<CargoFutureIncompatConfig>
§net_config: LazyCell<CargoNetConfig>
§build_config: LazyCell<CargoBuildConfig>
§target_cfgs: LazyCell<Vec<(String, TargetCfgConfig)>>
§doc_extern_map: LazyCell<RustdocExternMap>
§progress_config: ProgressConfig
§env_config: LazyCell<EnvConfig>
§nightly_features_allowed: bool
This should be false if:
- this is an artifact of the rustc distribution process for “stable” or for “beta”
- this is an
#[test]
that does not opt in withenable_nightly_features
- this is an integration test that uses
ProcessBuilder
that does not opt in withmasquerade_as_nightly_cargo
This should be true if: - this is an artifact of the rustc distribution process for “nightly”
- this is being used in the rustc distribution process internally
- this is a cargo executable that was built from source
- this is an
#[test]
that calledenable_nightly_features
- this is an integration test that uses
ProcessBuilder
that calledmasquerade_as_nightly_cargo
It’s public to allow tests use nightly features. NOTE: this should be set beforeconfigure()
. If calling this from an integration test, consider usingConfigBuilder::enable_nightly_features
instead.
ws_roots: RefCell<HashMap<PathBuf, WorkspaceRootConfig>>
WorkspaceRootConfigs that have been found
Implementations§
source§impl Config
impl Config
sourcepub fn new(shell: Shell, cwd: PathBuf, homedir: PathBuf) -> Config
pub fn new(shell: Shell, cwd: PathBuf, homedir: PathBuf) -> Config
Creates a new config instance.
This is typically used for tests or other special cases. default
is
preferred otherwise.
This does only minimal initialization. In particular, it does not load any config files from disk. Those will be loaded lazily as-needed.
sourcepub fn default() -> CargoResult<Config>
pub fn default() -> CargoResult<Config>
Creates a new Config instance, with all default settings.
This does only minimal initialization. In particular, it does not load any config files from disk. Those will be loaded lazily as-needed.
sourcepub fn home(&self) -> &Filesystem
pub fn home(&self) -> &Filesystem
Gets the user’s Cargo home directory (OS-dependent).
sourcepub fn diagnostic_home_config(&self) -> String
pub fn diagnostic_home_config(&self) -> String
Returns a path to display to the user with the location of their home config file (to only be used for displaying a diagnostics suggestion, such as recommending where to add a config value).
sourcepub fn git_path(&self) -> Filesystem
pub fn git_path(&self) -> Filesystem
Gets the Cargo Git directory (<cargo_home>/git
).
sourcepub fn registry_base_path(&self) -> Filesystem
pub fn registry_base_path(&self) -> Filesystem
Gets the Cargo base directory for all registry information (<cargo_home>/registry
).
sourcepub fn registry_index_path(&self) -> Filesystem
pub fn registry_index_path(&self) -> Filesystem
Gets the Cargo registry index directory (<cargo_home>/registry/index
).
sourcepub fn registry_cache_path(&self) -> Filesystem
pub fn registry_cache_path(&self) -> Filesystem
Gets the Cargo registry cache directory (<cargo_home>/registry/cache
).
sourcepub fn registry_source_path(&self) -> Filesystem
pub fn registry_source_path(&self) -> Filesystem
Gets the Cargo registry source directory (<cargo_home>/registry/src
).
sourcepub fn default_registry(&self) -> CargoResult<Option<String>>
pub fn default_registry(&self) -> CargoResult<Option<String>>
Gets the default Cargo registry.
sourcepub fn shell(&self) -> RefMut<'_, Shell>
pub fn shell(&self) -> RefMut<'_, Shell>
Gets a reference to the shell, e.g., for writing error messages.
sourcepub fn rustdoc(&self) -> CargoResult<&Path>
pub fn rustdoc(&self) -> CargoResult<&Path>
Gets the path to the rustdoc
executable.
sourcepub fn load_global_rustc(
&self,
ws: Option<&Workspace<'_>>
) -> CargoResult<Rustc>
pub fn load_global_rustc( &self, ws: Option<&Workspace<'_>> ) -> CargoResult<Rustc>
Gets the path to the rustc
executable.
sourcepub fn cargo_exe(&self) -> CargoResult<&Path>
pub fn cargo_exe(&self) -> CargoResult<&Path>
Gets the path to the cargo
executable.
sourcepub fn updated_sources(&self) -> RefMut<'_, HashSet<SourceId>>
pub fn updated_sources(&self) -> RefMut<'_, HashSet<SourceId>>
Which package sources have been updated, used to ensure it is only done once.
sourcepub fn credential_cache(
&self
) -> RefMut<'_, HashMap<CanonicalUrl, CredentialCacheValue>>
pub fn credential_cache( &self ) -> RefMut<'_, HashMap<CanonicalUrl, CredentialCacheValue>>
Cached credentials from credential providers or configuration.
sourcepub(crate) fn registry_config(
&self
) -> RefMut<'_, HashMap<SourceId, Option<RegistryConfig>>>
pub(crate) fn registry_config( &self ) -> RefMut<'_, HashMap<SourceId, Option<RegistryConfig>>>
Cache of already parsed registries from the [registries]
table.
sourcepub fn values(&self) -> CargoResult<&HashMap<String, ConfigValue>>
pub fn values(&self) -> CargoResult<&HashMap<String, ConfigValue>>
Gets all config values from disk.
This will lazy-load the values as necessary. Callers are responsible
for checking environment variables. Callers outside of the config
module should avoid using this.
sourcepub fn values_mut(&mut self) -> CargoResult<&mut HashMap<String, ConfigValue>>
pub fn values_mut(&mut self) -> CargoResult<&mut HashMap<String, ConfigValue>>
Gets a mutable copy of the on-disk config values.
This requires the config values to already have been loaded. This
currently only exists for cargo vendor
to remove the source
entries. This doesn’t respect environment variables. You should avoid
using this if possible.
pub fn set_values( &self, values: HashMap<String, ConfigValue> ) -> CargoResult<()>
sourcepub fn set_search_stop_path<P: Into<PathBuf>>(&mut self, path: P)
pub fn set_search_stop_path<P: Into<PathBuf>>(&mut self, path: P)
Sets the path where ancestor config file searching will stop. The given path is included, but its ancestors are not.
sourcepub fn reload_rooted_at<P: AsRef<Path>>(&mut self, path: P) -> CargoResult<()>
pub fn reload_rooted_at<P: AsRef<Path>>(&mut self, path: P) -> CargoResult<()>
Reloads on-disk configuration values, starting at the given path and walking up its ancestors.
sourcepub fn target_dir(&self) -> CargoResult<Option<Filesystem>>
pub fn target_dir(&self) -> CargoResult<Option<Filesystem>>
The target
output directory to use.
Returns None
if the user has not chosen an explicit directory.
Callers should prefer Workspace::target_dir
instead.
sourcefn get_cv(&self, key: &ConfigKey) -> CargoResult<Option<ConfigValue>>
fn get_cv(&self, key: &ConfigKey) -> CargoResult<Option<ConfigValue>>
Get a configuration value by key.
This does NOT look at environment variables. See get_cv_with_env
for
a variant that supports environment variables.
fn get_cv_helper( &self, key: &ConfigKey, vals: &HashMap<String, ConfigValue> ) -> CargoResult<Option<ConfigValue>>
sourcepub(crate) fn get_cv_with_env(&self, key: &ConfigKey) -> CargoResult<Option<CV>>
pub(crate) fn get_cv_with_env(&self, key: &ConfigKey) -> CargoResult<Option<CV>>
This is a helper for getting a CV from a file or env var.
sourcepub(crate) fn env(&self) -> impl Iterator<Item = (&str, &str)>
pub(crate) fn env(&self) -> impl Iterator<Item = (&str, &str)>
Returns all environment variables as an iterator, keeping only entries where both the key and value are valid UTF-8.
sourcefn env_keys(&self) -> impl Iterator<Item = &str>
fn env_keys(&self) -> impl Iterator<Item = &str>
Returns all environment variable keys, filtering out keys that are not valid UTF-8.
fn get_config_env<T>(&self, key: &ConfigKey) -> Result<OptValue<T>, ConfigError>where T: FromStr, <T as FromStr>::Err: Display,
sourcepub fn get_env(&self, key: impl AsRef<OsStr>) -> CargoResult<String>
pub fn get_env(&self, key: impl AsRef<OsStr>) -> CargoResult<String>
Get the value of environment variable key
through the Config
snapshot.
This can be used similarly to std::env::var
.
sourcepub fn get_env_os(&self, key: impl AsRef<OsStr>) -> Option<OsString>
pub fn get_env_os(&self, key: impl AsRef<OsStr>) -> Option<OsString>
Get the value of environment variable key
through the Config
snapshot.
This can be used similarly to std::env::var_os
.
fn check_environment_key_case_mismatch(&self, key: &ConfigKey)
sourcepub fn get_string(&self, key: &str) -> CargoResult<OptValue<String>>
pub fn get_string(&self, key: &str) -> CargoResult<OptValue<String>>
Get a string config value.
See get
for more details.
sourcepub fn get_path(&self, key: &str) -> CargoResult<OptValue<PathBuf>>
pub fn get_path(&self, key: &str) -> CargoResult<OptValue<PathBuf>>
Get a config value that is expected to be a path.
This returns a relative path if the value does not contain any
directory separators. See ConfigRelativePath::resolve_program
for
more details.
fn string_to_path(&self, value: &str, definition: &Definition) -> PathBuf
sourcepub fn get_list(
&self,
key: &str
) -> CargoResult<OptValue<Vec<(String, Definition)>>>
pub fn get_list( &self, key: &str ) -> CargoResult<OptValue<Vec<(String, Definition)>>>
Get a list of strings.
DO NOT USE outside of the config module. pub
will be removed in the
future.
NOTE: this does not support environment variables. Use get
instead
if you want that.
fn _get_list( &self, key: &ConfigKey ) -> CargoResult<OptValue<Vec<(String, Definition)>>>
sourcefn get_list_or_string(
&self,
key: &ConfigKey,
merge: bool
) -> CargoResult<Vec<(String, Definition)>>
fn get_list_or_string( &self, key: &ConfigKey, merge: bool ) -> CargoResult<Vec<(String, Definition)>>
Helper for StringList type to get something that is a string or list.
sourcefn get_env_list(
&self,
key: &ConfigKey,
output: &mut Vec<(String, Definition)>
) -> CargoResult<()>
fn get_env_list( &self, key: &ConfigKey, output: &mut Vec<(String, Definition)> ) -> CargoResult<()>
Internal method for getting an environment variable as a list.
sourcefn get_table(
&self,
key: &ConfigKey
) -> CargoResult<OptValue<HashMap<String, CV>>>
fn get_table( &self, key: &ConfigKey ) -> CargoResult<OptValue<HashMap<String, CV>>>
Low-level method for getting a config value as an OptValue<HashMap<String, CV>>
.
NOTE: This does not read from env. The caller is responsible for that.
sourcefn get_integer(&self, key: &ConfigKey) -> Result<OptValue<i64>, ConfigError>
fn get_integer(&self, key: &ConfigKey) -> Result<OptValue<i64>, ConfigError>
Low-level private method for getting a config value as an OptValue.
sourcefn get_bool(&self, key: &ConfigKey) -> Result<OptValue<bool>, ConfigError>
fn get_bool(&self, key: &ConfigKey) -> Result<OptValue<bool>, ConfigError>
Low-level private method for getting a config value as an OptValue.
sourcefn get_string_priv(
&self,
key: &ConfigKey
) -> Result<OptValue<String>, ConfigError>
fn get_string_priv( &self, key: &ConfigKey ) -> Result<OptValue<String>, ConfigError>
Low-level private method for getting a config value as an OptValue.
sourcefn expected<T>(&self, ty: &str, key: &ConfigKey, val: &CV) -> CargoResult<T>
fn expected<T>(&self, ty: &str, key: &ConfigKey, val: &CV) -> CargoResult<T>
Generate an error when the given value is the wrong type.
sourcepub fn configure(
&mut self,
verbose: u32,
quiet: bool,
color: Option<&str>,
frozen: bool,
locked: bool,
offline: bool,
target_dir: &Option<PathBuf>,
unstable_flags: &[String],
cli_config: &[String]
) -> CargoResult<()>
pub fn configure( &mut self, verbose: u32, quiet: bool, color: Option<&str>, frozen: bool, locked: bool, offline: bool, target_dir: &Option<PathBuf>, unstable_flags: &[String], cli_config: &[String] ) -> CargoResult<()>
Update the Config instance based on settings typically passed in on the command-line.
This may also load the config from disk if it hasn’t already been loaded.
fn load_unstable_flags_from_config(&mut self) -> CargoResult<()>
pub fn cli_unstable(&self) -> &CliUnstable
pub fn extra_verbose(&self) -> bool
pub fn network_allowed(&self) -> bool
pub fn offline(&self) -> bool
pub fn frozen(&self) -> bool
pub fn locked(&self) -> bool
pub fn lock_update_allowed(&self) -> bool
sourcepub fn load_values(&self) -> CargoResult<HashMap<String, ConfigValue>>
pub fn load_values(&self) -> CargoResult<HashMap<String, ConfigValue>>
Loads configuration from the filesystem.
sourcepub(crate) fn load_values_unmerged(&self) -> CargoResult<Vec<ConfigValue>>
pub(crate) fn load_values_unmerged(&self) -> CargoResult<Vec<ConfigValue>>
Like load_values
but without merging config values.
This is primarily crafted for cargo config
command.
sourcefn load_unmerged_include(
&self,
cv: &mut CV,
seen: &mut HashSet<PathBuf>,
output: &mut Vec<CV>
) -> CargoResult<()>
fn load_unmerged_include( &self, cv: &mut CV, seen: &mut HashSet<PathBuf>, output: &mut Vec<CV> ) -> CargoResult<()>
Like load_includes
but without merging config values.
This is primarily crafted for cargo config
command.
sourcefn load_values_from(
&self,
path: &Path
) -> CargoResult<HashMap<String, ConfigValue>>
fn load_values_from( &self, path: &Path ) -> CargoResult<HashMap<String, ConfigValue>>
Start a config file discovery from a path and merges all config values found.
sourcefn load_file(&self, path: &Path) -> CargoResult<ConfigValue>
fn load_file(&self, path: &Path) -> CargoResult<ConfigValue>
Loads a config value from a path.
This is used during config file discovery.
sourcefn _load_file(
&self,
path: &Path,
seen: &mut HashSet<PathBuf>,
includes: bool,
why_load: WhyLoad
) -> CargoResult<ConfigValue>
fn _load_file( &self, path: &Path, seen: &mut HashSet<PathBuf>, includes: bool, why_load: WhyLoad ) -> CargoResult<ConfigValue>
Loads a config value from a path with options.
This is actual implementation of loading a config value from a path.
includes
determines whether to load configs fromconfig-include
.seen
is used to check for cyclic includes.why_load
tells why a config is being loaded.
sourcefn load_includes(
&self,
value: CV,
seen: &mut HashSet<PathBuf>,
why_load: WhyLoad
) -> CargoResult<CV>
fn load_includes( &self, value: CV, seen: &mut HashSet<PathBuf>, why_load: WhyLoad ) -> CargoResult<CV>
Load any include
files listed in the given value
.
Returns value
with the given include files merged into it.
seen
is used to check for cyclic includes.why_load
tells why a config is being loaded.
sourcefn include_paths(
&self,
cv: &mut CV,
remove: bool
) -> CargoResult<Vec<(String, PathBuf, Definition)>>
fn include_paths( &self, cv: &mut CV, remove: bool ) -> CargoResult<Vec<(String, PathBuf, Definition)>>
Converts the include
config value to a list of absolute paths.
sourcepub(crate) fn cli_args_as_table(&self) -> CargoResult<ConfigValue>
pub(crate) fn cli_args_as_table(&self) -> CargoResult<ConfigValue>
Parses the CLI config args and returns them as a table.
sourcefn merge_cli_args(&mut self) -> CargoResult<()>
fn merge_cli_args(&mut self) -> CargoResult<()>
Add config arguments passed on the command line.
sourcefn get_file_path(
&self,
dir: &Path,
filename_without_extension: &str,
warn: bool
) -> CargoResult<Option<PathBuf>>
fn get_file_path( &self, dir: &Path, filename_without_extension: &str, warn: bool ) -> CargoResult<Option<PathBuf>>
The purpose of this function is to aid in the transition to using .toml extensions on Cargo’s config files, which were historically not used. Both ‘config.toml’ and ‘credentials.toml’ should be valid with or without extension. When both exist, we want to prefer the one without an extension for backwards compatibility, but warn the user appropriately.
fn walk_tree<F>(&self, pwd: &Path, home: &Path, walk: F) -> CargoResult<()>where F: FnMut(&Path) -> CargoResult<()>,
sourcepub fn get_registry_index(&self, registry: &str) -> CargoResult<Url>
pub fn get_registry_index(&self, registry: &str) -> CargoResult<Url>
Gets the index for a registry.
sourcepub fn check_registry_index_not_set(&self) -> CargoResult<()>
pub fn check_registry_index_not_set(&self) -> CargoResult<()>
Returns an error if registry.index
is set.
fn resolve_registry_index(&self, index: &Value<String>) -> CargoResult<Url>
sourcepub fn load_credentials(&self) -> CargoResult<()>
pub fn load_credentials(&self) -> CargoResult<()>
Loads credentials config from the credentials file, if present.
The credentials are loaded into a separate field to enable them
to be lazy-loaded after the main configuration has been loaded,
without requiring mut
access to the Config
.
If the credentials are already loaded, this function does nothing.
sourcefn maybe_get_tool(
&self,
tool: &str,
from_config: &Option<ConfigRelativePath>
) -> Option<PathBuf>
fn maybe_get_tool( &self, tool: &str, from_config: &Option<ConfigRelativePath> ) -> Option<PathBuf>
Looks for a path for tool
in an environment variable or the given config, and returns
None
if it’s not present.
sourcefn get_tool(
&self,
tool: Tool,
from_config: &Option<ConfigRelativePath>
) -> PathBuf
fn get_tool( &self, tool: Tool, from_config: &Option<ConfigRelativePath> ) -> PathBuf
Returns the path for the given tool.
This will look for the tool in the following order:
- From an environment variable matching the tool name (such as
RUSTC
). - From the given config value (which is usually something like
build.rustc
). - Finds the tool in the PATH environment variable.
This is intended for tools that are rustup proxies. If you need to get
a tool that is not a rustup proxy, use maybe_get_tool
instead.
pub fn jobserver_from_env(&self) -> Option<&Client>
pub fn http(&self) -> CargoResult<&RefCell<Easy>>
pub fn http_config(&self) -> CargoResult<&CargoHttpConfig>
pub fn future_incompat_config(&self) -> CargoResult<&CargoFutureIncompatConfig>
pub fn net_config(&self) -> CargoResult<&CargoNetConfig>
pub fn build_config(&self) -> CargoResult<&CargoBuildConfig>
pub fn progress_config(&self) -> &ProgressConfig
pub fn env_config(&self) -> CargoResult<&EnvConfig>
sourcepub fn validate_term_config(&self) -> CargoResult<()>
pub fn validate_term_config(&self) -> CargoResult<()>
This is used to validate the term
table has valid syntax.
This is necessary because loading the term settings happens very
early, and in some situations (like cargo version
) we don’t want to
fail if there are problems with the config file.
sourcepub fn target_cfgs(&self) -> CargoResult<&Vec<(String, TargetCfgConfig)>>
pub fn target_cfgs(&self) -> CargoResult<&Vec<(String, TargetCfgConfig)>>
Returns a list of [target.‘cfg()’] tables.
The list is sorted by the table name.
pub fn doc_extern_map(&self) -> CargoResult<&RustdocExternMap>
sourcepub fn target_applies_to_host(&self) -> CargoResult<bool>
pub fn target_applies_to_host(&self) -> CargoResult<bool>
Returns true if the [target]
table should be applied to host targets.
sourcepub fn host_cfg_triple(&self, target: &str) -> CargoResult<TargetConfig>
pub fn host_cfg_triple(&self, target: &str) -> CargoResult<TargetConfig>
Returns the [host]
table definition for the given target triple.
sourcepub fn target_cfg_triple(&self, target: &str) -> CargoResult<TargetConfig>
pub fn target_cfg_triple(&self, target: &str) -> CargoResult<TargetConfig>
Returns the [target]
table definition for the given target triple.
sourcepub fn crates_io_source_id(&self) -> CargoResult<SourceId>
pub fn crates_io_source_id(&self) -> CargoResult<SourceId>
Returns the cached SourceId
corresponding to the main repository.
This is the main cargo registry by default, but it can be overridden in
a .cargo/config.toml
.
pub fn creation_time(&self) -> Instant
sourcepub fn get<'de, T: Deserialize<'de>>(&self, key: &str) -> CargoResult<T>
pub fn get<'de, T: Deserialize<'de>>(&self, key: &str) -> CargoResult<T>
Retrieves a config variable.
This supports most serde Deserialize
types. Examples:
let v: Option<u32> = config.get("some.nested.key")?;
let v: Option<MyStruct> = config.get("some.key")?;
let v: Option<HashMap<String, MyStruct>> = config.get("foo")?;
The key may be a dotted key, but this does NOT support TOML key
quoting. Avoid key components that may have dots. For example,
foo.'a.b'.bar" does not work if you try to fetch
foo.‘a.b’“. You can
fetch foo
if it is a map, though.
pub fn assert_package_cache_locked<'a>(&self, f: &'a Filesystem) -> &'a Path
sourcepub fn acquire_package_cache_lock(&self) -> CargoResult<PackageCacheLock<'_>>
pub fn acquire_package_cache_lock(&self) -> CargoResult<PackageCacheLock<'_>>
Acquires an exclusive lock on the global “package cache”
This lock is global per-process and can be acquired recursively. An RAII structure is returned to release the lock, and if this process abnormally terminates the lock is also released.
pub fn release_package_cache_lock(&self)
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Config
impl !Send for Config
impl !Sync for Config
impl Unpin for Config
impl !UnwindSafe for Config
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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 1968 bytes