mpl_registry_api/
state.rs1use std::path::PathBuf;
4use std::sync::Arc;
5
6use crate::cache::SchemaCache;
7
8#[derive(Clone)]
10pub struct RegistryState {
11 pub registry_path: PathBuf,
13 pub cache: Arc<SchemaCache>,
15}
16
17impl RegistryState {
18 pub fn new(registry_path: PathBuf) -> Self {
20 Self {
21 registry_path,
22 cache: Arc::new(SchemaCache::new()),
23 }
24 }
25
26 pub fn stype_path(&self, namespace: &str, domain: &str, name: &str, version: u32) -> PathBuf {
28 self.registry_path
29 .join("stypes")
30 .join(namespace)
31 .join(domain)
32 .join(name)
33 .join(format!("v{}", version))
34 }
35
36 pub fn schema_path(&self, namespace: &str, domain: &str, name: &str, version: u32) -> PathBuf {
38 self.stype_path(namespace, domain, name, version)
39 .join("schema.json")
40 }
41
42 pub fn examples_path(&self, namespace: &str, domain: &str, name: &str, version: u32) -> PathBuf {
44 self.stype_path(namespace, domain, name, version)
45 .join("examples")
46 }
47}