rusty-beads 0.1.0

Git-backed graph issue tracker for AI coding agents - a Rust implementation with context store, dependency tracking, and semantic compaction
Documentation
//! Daemon configuration.

use serde::{Deserialize, Serialize};
use std::time::Duration;

/// Configuration for the daemon.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DaemonConfig {
    /// Whether to automatically commit changes.
    #[serde(default)]
    pub auto_commit: bool,

    /// Whether to automatically push to remote.
    #[serde(default)]
    pub auto_push: bool,

    /// Whether to automatically pull from remote.
    #[serde(default)]
    pub auto_pull: bool,

    /// Sync interval in seconds.
    #[serde(default = "default_interval")]
    pub interval_secs: u64,

    /// Request timeout in seconds.
    #[serde(default = "default_timeout")]
    pub timeout_secs: u64,

    /// Maximum concurrent connections.
    #[serde(default = "default_max_connections")]
    pub max_connections: usize,

    /// Log level.
    #[serde(default = "default_log_level")]
    pub log_level: String,

    /// Whether to output JSON logs.
    #[serde(default)]
    pub log_json: bool,

    /// Log file path (optional).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub log_file: Option<String>,
}

impl Default for DaemonConfig {
    fn default() -> Self {
        Self {
            auto_commit: false,
            auto_push: false,
            auto_pull: false,
            interval_secs: default_interval(),
            timeout_secs: default_timeout(),
            max_connections: default_max_connections(),
            log_level: default_log_level(),
            log_json: false,
            log_file: None,
        }
    }
}

impl DaemonConfig {
    /// Get the sync interval as a Duration.
    pub fn interval(&self) -> Duration {
        Duration::from_secs(self.interval_secs)
    }

    /// Get the request timeout as a Duration.
    pub fn timeout(&self) -> Duration {
        Duration::from_secs(self.timeout_secs)
    }
}

fn default_interval() -> u64 {
    5
}

fn default_timeout() -> u64 {
    30
}

fn default_max_connections() -> usize {
    100
}

fn default_log_level() -> String {
    "info".to_string()
}