use std::collections::HashMap;
use panproto_schema::Edge;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Migration {
pub vertex_map: HashMap<String, String>,
pub edge_map: HashMap<Edge, Edge>,
pub hyper_edge_map: HashMap<String, String>,
pub label_map: HashMap<(String, String), String>,
pub resolver: HashMap<(String, String), Edge>,
#[allow(clippy::type_complexity)]
pub hyper_resolver: HashMap<(String, Vec<String>), (String, HashMap<String, String>)>,
}
impl Migration {
#[must_use]
pub fn identity(vertices: &[String], edges: &[Edge]) -> Self {
let vertex_map: HashMap<String, String> =
vertices.iter().map(|v| (v.clone(), v.clone())).collect();
let edge_map: HashMap<Edge, Edge> = edges.iter().map(|e| (e.clone(), e.clone())).collect();
Self {
vertex_map,
edge_map,
hyper_edge_map: HashMap::new(),
label_map: HashMap::new(),
resolver: HashMap::new(),
hyper_resolver: HashMap::new(),
}
}
#[must_use]
pub fn empty() -> Self {
Self {
vertex_map: HashMap::new(),
edge_map: HashMap::new(),
hyper_edge_map: HashMap::new(),
label_map: HashMap::new(),
resolver: HashMap::new(),
hyper_resolver: HashMap::new(),
}
}
}