use serde::Deserialize;
use crate::store::StoreConfig;
#[derive(Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct Config {
pub private_key: String,
pub store: StoreConfig,
#[serde(default)]
pub core_capabilities: CoreCapabilities,
pub base_url: url::Url,
}
#[derive(Deserialize, Copy, Clone, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct CoreCapabilities {
#[serde(default = "CoreCapabilities::default_max_size_upload")]
pub max_size_upload: u64,
#[serde(default = "CoreCapabilities::default_max_concurrent_upload")]
pub max_concurrent_upload: u64,
#[serde(default = "CoreCapabilities::default_max_size_request")]
pub max_size_request: u64,
#[serde(default = "CoreCapabilities::default_max_concurrent_requests")]
pub max_concurrent_requests: u64,
#[serde(default = "CoreCapabilities::default_max_calls_in_request")]
pub max_calls_in_request: u64,
#[serde(default = "CoreCapabilities::default_max_objects_in_get")]
pub max_objects_in_get: u64,
#[serde(default = "CoreCapabilities::default_max_objects_in_set")]
pub max_objects_in_set: u64,
}
impl Default for CoreCapabilities {
fn default() -> Self {
Self {
max_size_upload: Self::default_max_size_upload(),
max_concurrent_upload: Self::default_max_concurrent_upload(),
max_size_request: Self::default_max_size_request(),
max_concurrent_requests: Self::default_max_concurrent_requests(),
max_calls_in_request: Self::default_max_calls_in_request(),
max_objects_in_get: Self::default_max_objects_in_get(),
max_objects_in_set: Self::default_max_objects_in_set(),
}
}
}
impl CoreCapabilities {
const fn default_max_size_upload() -> u64 {
50_000_000
}
const fn default_max_concurrent_upload() -> u64 {
4
}
const fn default_max_size_request() -> u64 {
10_000_000
}
const fn default_max_concurrent_requests() -> u64 {
4
}
const fn default_max_calls_in_request() -> u64 {
16
}
const fn default_max_objects_in_get() -> u64 {
500
}
const fn default_max_objects_in_set() -> u64 {
500
}
}