use panproto_gat::SiteRename;
use panproto_mig::Migration;
use panproto_schema::Schema;
use serde::{Deserialize, Serialize};
use crate::ObjectId;
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum Object {
Schema(Box<Schema>),
Migration {
src: ObjectId,
tgt: ObjectId,
mapping: Migration,
},
Commit(CommitObject),
Tag(TagObject),
}
impl Object {
#[must_use]
pub const fn type_name(&self) -> &'static str {
match self {
Self::Schema(_) => "schema",
Self::Migration { .. } => "migration",
Self::Commit(_) => "commit",
Self::Tag(_) => "tag",
}
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct CommitObject {
pub schema_id: ObjectId,
pub parents: Vec<ObjectId>,
pub migration_id: Option<ObjectId>,
pub protocol: String,
pub author: String,
pub timestamp: u64,
pub message: String,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub renames: Vec<SiteRename>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct TagObject {
pub target: ObjectId,
pub tagger: String,
pub timestamp: u64,
pub message: String,
}