pub struct SourceRecord { /* private fields */ }Expand description
One optional detailed-source table row selected by an expanded assertion key.
Codecs expand aliases before constructing this row; no serialized offset or compact alias participates in matching.
use morphir_core::metadata::{Assertion, AssertionKey, AssertionSource, Carrier,
DocumentId, Fact, GraphIndex, GraphName, ObjectTerm, SourceRecord};
use morphir_core::node_address::NodeUri;
use serde_json::json;
let subject = NodeUri::parse(
"morphir://ir/pkg/acme/orders?format=4.0.0#/module/api/value/submit-order"
).unwrap();
let predicate = NodeUri::parse(
"morphir://ir/pkg/acme/metadata?format=4.0.0#/module/lifecycle/value/deprecated"
).unwrap();
let owner = DocumentId::new("orders/spec.json").unwrap();
let fact = Fact::new(subject, predicate, ObjectTerm::value(json!(true)), GraphName::Default);
let key = AssertionKey::new(owner.clone(), Carrier::DocumentGraph, fact).unwrap();
let source = AssertionSource::Author { reference: "review/42".into() };
let record = SourceRecord::new(key.clone(), vec![source.clone()]).unwrap();
let mut graph = GraphIndex::new();
graph.insert(Assertion::new(key)).unwrap();
graph.apply_source_records(&owner, &[record]).unwrap();
assert_eq!(graph.assertions()[0].sources(), vec![source]);Implementations§
Source§impl SourceRecord
impl SourceRecord
Sourcepub fn new(
selector: AssertionKey,
sources: Vec<AssertionSource>,
) -> Result<Self, MetadataError>
pub fn new( selector: AssertionKey, sources: Vec<AssertionSource>, ) -> Result<Self, MetadataError>
Create a row with at least one tagged source.
Sourcepub fn selector(&self) -> &AssertionKey
pub fn selector(&self) -> &AssertionKey
The owner, semantic carrier and expanded fact selected by this row.
Sourcepub fn sources(&self) -> &[AssertionSource]
pub fn sources(&self) -> &[AssertionSource]
The complete source set, replacing the implicit document default.
Trait Implementations§
Source§impl Clone for SourceRecord
impl Clone for SourceRecord
Source§impl Debug for SourceRecord
impl Debug for SourceRecord
impl Eq for SourceRecord
Source§impl PartialEq for SourceRecord
impl PartialEq for SourceRecord
impl StructuralPartialEq for SourceRecord
Auto Trait Implementations§
impl Freeze for SourceRecord
impl RefUnwindSafe for SourceRecord
impl Send for SourceRecord
impl Sync for SourceRecord
impl Unpin for SourceRecord
impl UnsafeUnpin for SourceRecord
impl UnwindSafe for SourceRecord
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.