use super::{Config, ServerConfig};
use crate::KonarrClient;
impl Config {
#[cfg(feature = "models")]
pub async fn database(&self) -> Result<geekorm::ConnectionManager, crate::KonarrError> {
self.database.database().await
}
}
impl ServerConfig {
pub fn client(&self) -> Result<KonarrClient, crate::KonarrError> {
Ok(KonarrClient::init().base(self.api_url()?)?.build()?)
}
pub fn client_with_token(&self, token: String) -> Result<KonarrClient, crate::KonarrError> {
Ok(KonarrClient::init()
.base(self.api_url()?)?
.token(token)
.build()?)
}
pub fn client_with_credentials(
&self,
username: String,
password: String,
) -> Result<KonarrClient, crate::KonarrError> {
Ok(KonarrClient::init()
.base(self.api_url()?)?
.credentials(username, password)
.build()?)
}
}