mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-14 13:52:11 +00:00
prototype
This commit is contained in:
1 parent
7ad2fd255e
commit
4dc1f0b7e3
5 files changed
+52
-1
No files matched your search
@@ -1,3 +1,4 @@
|
||||
pub mod payload;
|
||||
pub mod provider_credential_key;
|
||||
pub mod provider_credential_loading_cache;
|
||||
pub mod provider_credential_type;
|
||||
@@ -2,6 +2,7 @@ use std::error::Error;
|
||||
use std::fmt::Display;
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ApiKeyData(String);
|
||||
|
||||
impl ApiKeyData {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
use crate::core::providers::payload::api_key::ApiKeyData;
|
||||
use crate::core::providers::payload::web_login::WebLoginData;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum ProviderCredentialPayload {
|
||||
ApiKey(ApiKeyData),
|
||||
|
||||
// TODO: There might be logins in the future that use weird header states, etc.
|
||||
WebLogin (WebLoginData),
|
||||
WebLogin(WebLoginData),
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use std::path::Path;
|
||||
|
||||
const CURRENT_VERSION: u8 = 1;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct WebLoginData {
|
||||
pub cookies_header: Option<String>,
|
||||
pub additional_headers: Option<HashMap<String, String>>,
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
use std::error::Error;
|
||||
use std::fmt::Display;
|
||||
use crate::core::providers::payload::provider_credential_payload::ProviderCredentialPayload;
|
||||
use crate::core::providers::provider_credential_key::ProviderCredentialKey;
|
||||
use crate::core::state::data_dir::app_data_root::AppDataRoot;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ProviderCredentialLoadingCache {
|
||||
// TODO: Some kind of Arc<Lock<Cache<key,value>>>
|
||||
app_data_root: AppDataRoot,
|
||||
}
|
||||
|
||||
impl ProviderCredentialLoadingCache {
|
||||
|
||||
pub fn new(app_data_root: AppDataRoot) -> Self {
|
||||
Self {
|
||||
app_data_root,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_credentials(&self, key: ProviderCredentialKey) -> Result<Option<ProviderCredentialPayload>, ProviderCredentialLoadingCacheError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn save_credentials(&self, key: ProviderCredentialKey, payload: ProviderCredentialPayload) -> Result<(), ProviderCredentialLoadingCacheError> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ProviderCredentialLoadingCacheError {
|
||||
IoError(std::io::Error),
|
||||
}
|
||||
|
||||
impl Error for ProviderCredentialLoadingCacheError {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match self {
|
||||
ProviderCredentialLoadingCacheError::IoError(err) => Some(err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for ProviderCredentialLoadingCacheError {
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user