dpp_domain/schemas/
types.rs1use semver::Version;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8#[non_exhaustive]
9pub enum SchemaOrigin {
10 Embedded,
12 Runtime,
14}
15
16#[derive(Debug, Clone)]
18pub struct SchemaEntry {
19 pub sector: String,
20 pub version: Version,
21 pub json: String,
22 pub origin: SchemaOrigin,
23}
24
25#[derive(Debug, Clone, PartialEq, Eq)]
27#[non_exhaustive]
28pub enum SchemaRegistrationError {
29 InvalidJson(String),
31 AlreadyExists { sector: String, version: Version },
34 InvalidVersion(String),
36}
37
38impl std::fmt::Display for SchemaRegistrationError {
39 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40 match self {
41 Self::InvalidJson(msg) => write!(f, "invalid JSON schema: {msg}"),
42 Self::AlreadyExists { sector, version } => {
43 write!(f, "schema already exists for {sector} v{version}")
44 }
45 Self::InvalidVersion(v) => write!(f, "invalid semver version: {v}"),
46 }
47 }
48}
49
50impl std::error::Error for SchemaRegistrationError {}