aboutsummaryrefslogtreecommitdiffstats
path: root/lib/api-config/src/schema/mod.rs
blob: 654e6ad055d6be6b998d03d289463f859cc144b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
pub mod create;

use serde::{Deserialize, Serialize};
use time::OffsetDateTime;

use crate::ConfigurationError;

/// Transaction to monitor
#[derive(Deserialize, Serialize)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct TransactionSchema {
    #[serde(rename = "type")]
    /// Transaction schema type
    pub kind: String,
    /// The schema's version
    pub version: String,
    /// JSON schema for transcation
    #[serde(rename = "json_schema")]
    pub schema: serde_json::Value,
    #[serde(with = "time::serde::rfc3339")]
    pub created_at: OffsetDateTime,
    #[serde(with = "time::serde::rfc3339")]
    pub updated_at: OffsetDateTime,
}

pub trait SchemaDriver {
    fn create(
        &self,
        name: impl AsRef<str>,
        version: impl AsRef<str>,
        schema: serde_json::Value,
    ) -> impl std::future::Future<Output = Result<TransactionSchema, ConfigurationError>> + Send + Sync;
}