canon_protocol/
repository.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Serialize, Deserialize)]
5pub struct CanonRepository {
6 pub canon: String,
7 pub registry: RegistryConfig,
8 pub dependencies: Vec<String>,
9}
10
11#[derive(Debug, Serialize, Deserialize)]
12pub struct RegistryConfig {
13 pub default: String,
14}
15
16impl CanonRepository {
17 pub fn new() -> Self {
19 Self {
20 canon: "1.0".to_string(),
21 registry: RegistryConfig {
22 default: "https://spec.farm".to_string(),
23 },
24 dependencies: vec![
25 "canon-protocol.org/type@1.0.0".to_string(),
26 "canon-protocol.org/transformation@1.0.0".to_string(),
27 "canon-protocol.org/auto-version@1.0.0".to_string(),
28 ],
29 }
30 }
31
32 pub fn add_dependency(&mut self, uri: String) {
34 if !self.dependencies.contains(&uri) {
35 self.dependencies.push(uri);
36 }
37 }
38}
39
40impl Default for CanonRepository {
41 fn default() -> Self {
42 Self::new()
43 }
44}