Skip to content

Commit 7956f03

Browse files
committed
Add some doc-strings to registry functions.
1 parent 235beb0 commit 7956f03

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/cargo/ops/registry.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ use crate::util::IntoUrl;
2525
use crate::util::{paths, validate_package_name};
2626
use crate::version;
2727

28+
/// Registry settings loaded from config files.
29+
///
30+
/// This is loaded based on the `--registry` flag and the config settings.
2831
pub struct RegistryConfig {
32+
/// The index URL. If `None`, use crates.io.
2933
pub index: Option<String>,
34+
/// The authentication token.
3035
pub token: Option<String>,
3136
}
3237

@@ -316,10 +321,15 @@ fn transmit(
316321
}
317322
}
318323

324+
/// Returns the index and token from the config file for the given registry.
325+
///
326+
/// `registry` is typically the registry specified on the command-line. If
327+
/// `None`, returns the default index.
319328
pub fn registry_configuration(
320329
config: &Config,
321330
registry: Option<String>,
322331
) -> CargoResult<RegistryConfig> {
332+
// `registry.default` is handled in command-line parsing.
323333
let (index, token) = match registry {
324334
Some(registry) => {
325335
validate_package_name(&registry, "registry name", "")?;
@@ -344,6 +354,17 @@ pub fn registry_configuration(
344354
Ok(RegistryConfig { index, token })
345355
}
346356

357+
/// Returns the `Registry` and `Source` based on command-line and config settings.
358+
///
359+
/// * `token`: The token from the command-line. If not set, uses the token
360+
/// from the config.
361+
/// * `index`: The index URL from the command-line. This is ignored if
362+
/// `registry` is set.
363+
/// * `registry`: The registry name from the command-line. If neither
364+
/// `registry`, or `index` are set, then uses `crates-io`, honoring
365+
/// `[source]` replacement if defined.
366+
/// * `force_update`: If `true`, forces the index to be updated.
367+
/// * `validate_token`: If `true`, the token must be set.
347368
fn registry(
348369
config: &Config,
349370
token: Option<String>,
@@ -739,6 +760,10 @@ pub fn yank(
739760
Ok(())
740761
}
741762

763+
/// Gets the SourceId for an index or registry setting.
764+
///
765+
/// The `index` and `reg` values are from the command-line or config settings.
766+
/// If both are None, returns the source for crates.io.
742767
fn get_source_id(
743768
config: &Config,
744769
index: Option<String>,

0 commit comments

Comments
 (0)