use std::sync::Arc;
use sqry_core::graph::unified::concurrent::GraphSnapshot;
pub mod diff;
pub use diff::{ChangeType, DiffOptions, DiffOutput, DiffSummary, NodeChange, NodeLocation};
pub struct ComparativeQueryDb {
old: Arc<GraphSnapshot>,
new: Arc<GraphSnapshot>,
}
impl ComparativeQueryDb {
#[must_use]
pub fn new(old: Arc<GraphSnapshot>, new: Arc<GraphSnapshot>) -> Self {
Self { old, new }
}
#[inline]
#[must_use]
pub fn old(&self) -> &GraphSnapshot {
&self.old
}
#[inline]
#[must_use]
pub fn new_snapshot(&self) -> &GraphSnapshot {
&self.new
}
#[inline]
#[must_use]
pub fn old_arc(&self) -> Arc<GraphSnapshot> {
Arc::clone(&self.old)
}
#[inline]
#[must_use]
pub fn new_arc(&self) -> Arc<GraphSnapshot> {
Arc::clone(&self.new)
}
#[must_use]
pub fn diff(&self, opts: &DiffOptions) -> DiffOutput {
diff::compute_diff(&self.old, &self.new, opts)
}
#[must_use]
pub fn diff_default(&self) -> DiffOutput {
self.diff(&DiffOptions::default())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn comparative_query_db_is_send_sync() {
fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<ComparativeQueryDb>();
}
}