mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-05 10:49:40 +02:00
Small refactor of librespot-core
* Remove default impl for `SessionConfig` * Move util mod to single file * Restore privacy of mods * Move `fn get_credentials` to application * Remove `extern crate` statements
This commit is contained in:
parent
c0942f14e8
commit
9253be7bc9
8 changed files with 31 additions and 85 deletions
|
@ -142,30 +142,6 @@ where
|
|||
base64::decode(&v).map_err(|e| serde::de::Error::custom(e.to_string()))
|
||||
}
|
||||
|
||||
pub fn get_credentials<F: FnOnce(&String) -> String>(
|
||||
username: Option<String>,
|
||||
password: Option<String>,
|
||||
cached_credentials: Option<Credentials>,
|
||||
prompt: F,
|
||||
) -> Option<Credentials> {
|
||||
match (username, password, cached_credentials) {
|
||||
(Some(username), Some(password), _) => Some(Credentials::with_password(username, password)),
|
||||
|
||||
(Some(ref username), _, Some(ref credentials)) if *username == credentials.username => {
|
||||
Some(credentials.clone())
|
||||
}
|
||||
|
||||
(Some(username), None, _) => Some(Credentials::with_password(
|
||||
username.clone(),
|
||||
prompt(&username),
|
||||
)),
|
||||
|
||||
(None, _, Some(credentials)) => Some(credentials),
|
||||
|
||||
(None, _, None) => None,
|
||||
}
|
||||
}
|
||||
|
||||
error_chain! {
|
||||
types {
|
||||
AuthenticationError, AuthenticationErrorKind, AuthenticationResultExt, AuthenticationResult;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue