use std::time::Duration;
#[derive(Debug, Clone)]
pub struct FetchOptions {
pub allowed_hosts: Option<Vec<String>>,
pub allow_private_networks: bool,
pub private_hosts: Vec<String>,
pub max_response_bytes: u64,
pub max_concurrent: usize,
pub max_per_request: u32,
pub connect_timeout: Duration,
pub timeout: Duration,
pub pool_max_idle_per_host: usize,
pub max_retries: u32,
pub proxy: Option<String>,
pub no_proxy: bool,
pub propagate_trace_context: bool,
}
impl Default for FetchOptions {
fn default() -> Self {
Self {
allowed_hosts: None,
allow_private_networks: false,
private_hosts: Vec::new(),
max_response_bytes: 8 * 1024 * 1024, max_concurrent: 8,
max_per_request: 32,
connect_timeout: Duration::from_secs(10),
timeout: Duration::from_secs(30),
pool_max_idle_per_host: 8,
max_retries: 5,
proxy: None,
no_proxy: false,
propagate_trace_context: false,
}
}
}
#[derive(Debug, Clone, Default)]
pub struct EnvOptions {
pub allow: Option<Vec<String>>,
pub mode: RunMode,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum RunMode {
#[default]
Run,
Dev,
Test,
}
impl RunMode {
pub fn as_str(self) -> &'static str {
match self {
Self::Run => "run",
Self::Dev => "dev",
Self::Test => "test",
}
}
}
#[derive(Debug, Clone)]
pub struct SqlitePragmas {
pub journal_mode: String,
pub busy_timeout: u64,
pub synchronous: String,
pub foreign_keys: bool,
pub cache_size: i64,
pub max_rows: usize,
}
impl Default for SqlitePragmas {
fn default() -> Self {
Self {
journal_mode: "wal".into(),
busy_timeout: 5_000,
synchronous: "normal".into(),
foreign_keys: true,
cache_size: -2_000,
max_rows: 10_000,
}
}
}
pub const MAX_PASSWORD_BYTES: usize = 1024;