use std::time::Duration;
use crate::records::SafetyEnvelope;
use printobserver_types::PrintId;
pub const PRINT_ID_PLACEHOLDER: &str = "{print_id}";
pub const DEFAULT_EXPIRY_POLL: Duration = Duration::from_millis(250);
pub const DEFAULT_RECENT_EVENTS: u32 = 20;
#[derive(Debug, Clone, PartialEq)]
pub struct CoreConfig {
pub envelope: SafetyEnvelope,
pub context_command: String,
pub recent_events: u32,
pub expiry_poll: Duration,
}
impl CoreConfig {
#[must_use]
pub fn new(envelope: SafetyEnvelope, context_command: String) -> Self {
Self {
envelope,
context_command,
recent_events: DEFAULT_RECENT_EVENTS,
expiry_poll: DEFAULT_EXPIRY_POLL,
}
}
#[must_use]
pub fn context_command_for(&self, print_id: PrintId) -> String {
self.context_command
.replace(PRINT_ID_PLACEHOLDER, &print_id.to_string())
}
}