#![allow(non_snake_case, non_camel_case_types)]
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
pub type Guid = String;
pub type DeltaDataTypeLong = i64;
pub type DeltaDataTypeVersion = DeltaDataTypeLong;
pub type DeltaDataTypeTimestamp = DeltaDataTypeLong;
pub type DeltaDataTypeInt = i32;
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
pub struct SchemaTypeStruct {
r#type: String,
fields: Vec<SchemaField>,
}
impl SchemaTypeStruct {
pub fn get_fields(&self) -> &Vec<SchemaField> {
&self.fields
}
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SchemaField {
name: String,
r#type: SchemaDataType,
nullable: bool,
metadata: HashMap<String, String>,
}
impl SchemaField {
pub fn get_name(&self) -> &str {
&self.name
}
pub fn get_type(&self) -> &SchemaDataType {
&self.r#type
}
pub fn is_nullable(&self) -> bool {
self.nullable
}
pub fn get_metadata(&self) -> &HashMap<String, String> {
&self.metadata
}
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SchemaTypeArray {
r#type: String,
elementType: Box<SchemaDataType>,
containsNull: bool,
}
impl SchemaTypeArray {
pub fn get_element_type(&self) -> &SchemaDataType {
&self.elementType
}
pub fn contains_null(&self) -> bool {
self.containsNull
}
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SchemaTypeMap {
r#type: String,
keyType: Box<SchemaDataType>,
valueType: Box<SchemaDataType>,
valueContainsNull: bool,
}
impl SchemaTypeMap {
pub fn get_key_type(&self) -> &SchemaDataType {
&self.keyType
}
pub fn get_value_type(&self) -> &SchemaDataType {
&self.valueType
}
pub fn get_value_contains_null(&self) -> bool {
self.valueContainsNull
}
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(untagged)]
pub enum SchemaDataType {
primitive(String),
r#struct(SchemaTypeStruct),
array(SchemaTypeArray),
map(SchemaTypeMap),
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Schema {
r#type: String,
fields: Vec<SchemaField>,
}
impl Schema {
pub fn get_fields(&self) -> &Vec<SchemaField> {
&self.fields
}
}