registry_testkit/
config.rs1use std::path::PathBuf;
2
3#[derive(Debug, Clone)]
4pub enum StorageBackend {
5 Memory,
6 TempDir,
7 Directory(PathBuf),
8}
9
10#[derive(Debug, Clone)]
11pub struct RegistryConfig {
12 pub storage: StorageBackend,
13 pub port: Option<u16>,
14 pub host: String,
15}
16
17impl RegistryConfig {
18 pub fn new(storage: StorageBackend) -> Self {
19 Self {
20 storage,
21 port: None,
22 host: "127.0.0.1".to_string(),
23 }
24 }
25
26 pub fn memory() -> Self {
27 Self::new(StorageBackend::Memory)
28 }
29
30 pub fn temp_dir() -> Self {
31 Self::new(StorageBackend::TempDir)
32 }
33
34 pub fn directory(path: PathBuf) -> Self {
35 Self::new(StorageBackend::Directory(path))
36 }
37
38 pub fn with_port(mut self, port: u16) -> Self {
39 self.port = Some(port);
40 self
41 }
42
43 pub fn with_host(mut self, host: impl Into<String>) -> Self {
44 self.host = host.into();
45 self
46 }
47}
48
49impl Default for RegistryConfig {
50 fn default() -> Self {
51 Self::memory()
52 }
53}