Skip to main content

mockforge_runtime_daemon/
lib.rs

1//! # MockForge Runtime Daemon
2//!
3//! Zero-config mode runtime daemon that automatically creates mocks from 404 responses.
4//!
5//! This crate provides the "invisible mock server" experience - when a user hits an endpoint
6//! that doesn't exist, the daemon automatically:
7//! - Creates a mock endpoint
8//! - Generates a type
9//! - Generates a client stub
10//! - Adds to OpenAPI schema
11//! - Adds an example response
12//! - Sets up a scenario
13//!
14//! This is "mock server in your shadow" — an AI-assisted backend-on-demand.
15
16pub mod auto_generator;
17pub mod config;
18pub mod detector;
19
20pub use auto_generator::AutoGenerator;
21pub use config::RuntimeDaemonConfig;
22pub use detector::NotFoundDetector;
23
24/// Runtime daemon for auto-creating mocks from 404s
25pub struct RuntimeDaemon {
26    /// Configuration for the daemon
27    config: RuntimeDaemonConfig,
28}
29
30impl RuntimeDaemon {
31    /// Create a new runtime daemon with the given configuration
32    pub fn new(config: RuntimeDaemonConfig) -> Self {
33        Self { config }
34    }
35
36    /// Check if the daemon is enabled
37    pub fn is_enabled(&self) -> bool {
38        self.config.enabled
39    }
40
41    /// Get the configuration
42    pub fn config(&self) -> &RuntimeDaemonConfig {
43        &self.config
44    }
45}
46
47#[cfg(test)]
48mod tests {
49    use super::*;
50
51    #[test]
52    fn test_daemon_creation() {
53        let config = RuntimeDaemonConfig::default();
54        let daemon = RuntimeDaemon::new(config);
55        assert!(!daemon.is_enabled()); // Default should be disabled
56    }
57}