#[cfg(feature = "diesel")]
pub mod diesel;
mod error;
pub use error::SchemaStoreError;
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Schema {
pub name: String,
pub description: String,
pub owner: String,
pub properties: Vec<PropertyDefinition>,
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_id: Option<String>,
pub start_commit_num: i64,
pub end_commit_num: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PropertyDefinition {
pub start_commit_num: i64,
pub end_commit_num: i64,
pub name: String,
pub schema_name: String,
pub data_type: String,
pub required: bool,
pub description: String,
pub number_exponent: i64,
pub enum_options: Vec<String>,
pub struct_properties: Vec<PropertyDefinition>,
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_id: Option<String>,
}
pub trait SchemaStore: Send + Sync {
fn add_schema(&self, schema: Schema) -> Result<(), SchemaStoreError>;
fn fetch_schema(
&self,
name: &str,
service_id: Option<&str>,
) -> Result<Option<Schema>, SchemaStoreError>;
fn list_schemas(&self, service_id: Option<&str>) -> Result<Vec<Schema>, SchemaStoreError>;
fn list_property_definitions(
&self,
service_id: Option<&str>,
) -> Result<Vec<PropertyDefinition>, SchemaStoreError>;
fn list_property_definitions_with_schema_name(
&self,
schema_name: &str,
service_id: Option<&str>,
) -> Result<Vec<PropertyDefinition>, SchemaStoreError>;
fn get_property_definition_by_name(
&self,
schema_name: &str,
definition_name: &str,
service_id: Option<&str>,
) -> Result<Option<PropertyDefinition>, SchemaStoreError>;
}