use std::str::FromStr;
#[derive(Debug, Clone, PartialEq)]
pub enum MetadataScope {
Undefined,
FieldSession,
CollectionSession,
Series,
Dataset,
FeatureType,
Feature,
AttributeType,
Attribute,
Tile,
Model,
Catalog,
Schema,
Taxonomy,
Software,
Service,
CollectionHardware,
NonGeographicDataset,
DimensionGroup,
}
impl MetadataScope {
pub fn as_str(&self) -> &'static str {
match self {
Self::Undefined => "undefined",
Self::FieldSession => "fieldSession",
Self::CollectionSession => "collectionSession",
Self::Series => "series",
Self::Dataset => "dataset",
Self::FeatureType => "featureType",
Self::Feature => "feature",
Self::AttributeType => "attributeType",
Self::Attribute => "attribute",
Self::Tile => "tile",
Self::Model => "model",
Self::Catalog => "catalog",
Self::Schema => "schema",
Self::Taxonomy => "taxonomy",
Self::Software => "software",
Self::Service => "service",
Self::CollectionHardware => "collectionHardware",
Self::NonGeographicDataset => "nonGeographicDataset",
Self::DimensionGroup => "dimensionGroup",
}
}
}
impl FromStr for MetadataScope {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let scope = match s {
"undefined" => Self::Undefined,
"fieldSession" => Self::FieldSession,
"collectionSession" => Self::CollectionSession,
"series" => Self::Series,
"dataset" => Self::Dataset,
"featureType" => Self::FeatureType,
"feature" => Self::Feature,
"attributeType" => Self::AttributeType,
"attribute" => Self::Attribute,
"tile" => Self::Tile,
"model" => Self::Model,
"catalog" => Self::Catalog,
"schema" => Self::Schema,
"taxonomy" => Self::Taxonomy,
"software" => Self::Software,
"service" => Self::Service,
"collectionHardware" => Self::CollectionHardware,
"nonGeographicDataset" => Self::NonGeographicDataset,
"dimensionGroup" => Self::DimensionGroup,
_ => Self::Undefined,
};
Ok(scope)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct GpkgMetadata {
pub id: i64,
pub md_scope: MetadataScope,
pub md_standard_uri: String,
pub mime_type: String,
pub metadata: String,
}
#[derive(Debug, Clone, PartialEq)]
pub enum ReferenceScope {
GeoPackage,
Table,
Column,
Row,
RowCol,
}
impl ReferenceScope {
pub fn as_str(&self) -> &'static str {
match self {
Self::GeoPackage => "geopackage",
Self::Table => "table",
Self::Column => "column",
Self::Row => "row",
Self::RowCol => "row/col",
}
}
}
impl FromStr for ReferenceScope {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let scope = match s {
"geopackage" => Self::GeoPackage,
"table" => Self::Table,
"column" => Self::Column,
"row" => Self::Row,
"row/col" => Self::RowCol,
_ => Self::GeoPackage,
};
Ok(scope)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct GpkgMetadataReference {
pub reference_scope: ReferenceScope,
pub table_name: Option<String>,
pub column_name: Option<String>,
pub row_id_value: Option<i64>,
pub timestamp: String,
pub md_file_id: i64,
pub md_parent_id: Option<i64>,
}