Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

This crate runs on several different platforms, and on each one
it provides (by default) an implementation of a default credential store used
on that platform (see [builtin_credential_builder]).

Check warning on line 50 in src/lib.rs

View workflow job for this annotation

GitHub Actions / doc_build (x86_64-unknown-linux-gnu)

unresolved link to `builtin_credential_builder`

Check warning on line 50 in src/lib.rs

View workflow job for this annotation

GitHub Actions / doc_build (x86_64-pc-windows-msvc)

unresolved link to `builtin_credential_builder`

Check warning on line 50 in src/lib.rs

View workflow job for this annotation

GitHub Actions / doc_build (aarch64-apple-darwin)

unresolved link to `builtin_credential_builder`

Check warning on line 50 in src/lib.rs

View workflow job for this annotation

GitHub Actions / doc_build (aarch64-apple-ios)

unresolved link to `builtin_credential_builder`
These implementations work by mapping the data used to identify an entry
to data used to identify platform-specific storage objects.
For example, on macOS, the service and user provided for an entry
Expand Down Expand Up @@ -253,14 +253,12 @@
}

fn build_default_credential(target: Option<&str>, service: &str, user: &str) -> Result<Entry> {
static DEFAULT: std::sync::OnceLock<Box<CredentialBuilder>> = std::sync::OnceLock::new();
static DEFAULT: std::sync::LazyLock<Box<CredentialBuilder>> =
std::sync::LazyLock::new(default_credential_builder);
let guard = DEFAULT_BUILDER
.read()
.expect("Poisoned RwLock in keyring-rs: please report a bug!");
let builder = guard
.inner
.as_ref()
.unwrap_or_else(|| DEFAULT.get_or_init(|| default_credential_builder()));
let builder = guard.inner.as_ref().unwrap_or_else(|| &DEFAULT);
let credential = builder.build(target, service, user)?;
Ok(Entry { inner: credential })
}
Expand Down