pub struct GraphDelta {
pub deltas: Vec<DeltaType>,
pub baseline_hash: Option<String>,
pub current_hash: Option<String>,
pub computed_at: DateTime<Utc>,
}Expand description
Collection of deltas representing the difference between two graphs
A GraphDelta contains all changes detected between a baseline graph and
a current graph, along with metadata for tracking and verification.
§Examples
use ggen_core::delta::GraphDelta;
use ggen_core::graph::Graph;
let baseline = Graph::new()?;
baseline.insert_turtle(r#"
@prefix ex: <http://example.org/> .
ex:alice a ex:Person .
"#)?;
let current = Graph::new()?;
current.insert_turtle(r#"
@prefix ex: <http://example.org/> .
ex:alice a ex:Person .
ex:bob a ex:Person .
"#)?;
let delta = GraphDelta::new(&baseline, ¤t)?;
println!("Detected {} changes", delta.deltas.len());Fields§
§deltas: Vec<DeltaType>All detected changes
baseline_hash: Option<String>Hash of the baseline graph
current_hash: Option<String>Hash of the current graph
computed_at: DateTime<Utc>Timestamp when delta was computed
Implementations§
Source§impl GraphDelta
impl GraphDelta
Sourcepub fn new(baseline: &Graph, current: &Graph) -> Result<Self>
pub fn new(baseline: &Graph, current: &Graph) -> Result<Self>
Create a new delta by comparing two graphs
Computes all differences between the baseline and current graphs, including additions, deletions, and modifications.
§Examples
use ggen_core::delta::GraphDelta;
use ggen_core::graph::Graph;
let baseline = Graph::new()?;
let current = Graph::new()?;
current.insert_turtle(r#"
@prefix ex: <http://example.org/> .
ex:alice ex:name "Alice" .
"#)?;
let delta = GraphDelta::new(&baseline, ¤t)?;
assert!(!delta.deltas.is_empty());Sourcepub fn affected_iris(&self) -> BTreeSet<String>
pub fn affected_iris(&self) -> BTreeSet<String>
Get all IRIs affected by this delta
Returns a set of all unique IRIs (subjects, predicates, objects) that appear in any of the changes.
§Examples
use ggen_core::delta::GraphDelta;
use ggen_core::graph::Graph;
let baseline = Graph::new()?;
let current = Graph::new()?;
current.insert_turtle(r#"
@prefix ex: <http://example.org/> .
ex:alice ex:name "Alice" .
"#)?;
let delta = GraphDelta::new(&baseline, ¤t)?;
let affected = delta.affected_iris();
assert!(affected.contains("http://example.org/alice"));Sourcepub fn affects_iri(&self, iri: &str) -> bool
pub fn affects_iri(&self, iri: &str) -> bool
Check if this delta affects a specific IRI
Returns true if any change in this delta affects the given IRI
(as subject, predicate, or object).
§Examples
use ggen_core::delta::GraphDelta;
use ggen_core::graph::Graph;
let baseline = Graph::new()?;
let current = Graph::new()?;
current.insert_turtle(r#"
@prefix ex: <http://example.org/> .
ex:alice ex:name "Alice" .
"#)?;
let delta = GraphDelta::new(&baseline, ¤t)?;
assert!(delta.affects_iri("http://example.org/alice"));Sourcepub fn filter_by_iris(&self, iris: &[String]) -> Self
pub fn filter_by_iris(&self, iris: &[String]) -> Self
Filter deltas to only those affecting specific IRIs
Sourcepub fn merge(&mut self, other: GraphDelta)
pub fn merge(&mut self, other: GraphDelta)
Merge another delta into this one
Trait Implementations§
Source§impl Clone for GraphDelta
impl Clone for GraphDelta
Source§fn clone(&self) -> GraphDelta
fn clone(&self) -> GraphDelta
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GraphDelta
impl Debug for GraphDelta
Source§impl Default for GraphDelta
impl Default for GraphDelta
Source§fn default() -> GraphDelta
fn default() -> GraphDelta
Source§impl<'de> Deserialize<'de> for GraphDelta
impl<'de> Deserialize<'de> for GraphDelta
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for GraphDelta
impl Display for GraphDelta
Auto Trait Implementations§
impl Freeze for GraphDelta
impl RefUnwindSafe for GraphDelta
impl Send for GraphDelta
impl Sync for GraphDelta
impl Unpin for GraphDelta
impl UnwindSafe for GraphDelta
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.