pub struct Relation {
pub source: String,
pub target: String,
pub kind: RelationKind,
pub field: Option<String>,
pub target_data_model: Option<String>,
pub is_builtin: bool,
}Expand description
A directed edge between two resource-types in (or out of) a data-model.
Two kinds: a link relation (a link field on the source resource-type
points to the target; the field name labels the relation — field is Some)
and an inheritance relation (the source extends the target as a superclass
— field is None). Carries a target_data_model tag for cross-data-model
targets (mirroring Field.data_model in the target direction) and an
is_builtin flag whose meaning is asymmetric by kind (see below).
Invariants (asserted in unit tests; not enforced structurally — same
precedent as Field.link_target in resource_type.rs):
- (a)
field.is_some()iffkind == RelationKind::Link. - (b)
target_data_model == Nonewhenever the target is in a system namespace (knora-api,knora-base, etc.).
No serde derive: wire deserialization stays in src/client/http.rs. See
ADR-0001 / ADR-0008 and the CONTEXT.md “Relation” entry.
Fields§
§source: StringSource resource-type local name (IRI fragment, e.g. letter).
target: StringTarget resource-type or superclass local name (IRI fragment, e.g. person
or writtenSource).
kind: RelationKindWhether this is a link relation or an inheritance relation.
field: Option<String>The link-field local name that labels this relation (e.g. hasSender).
Some iff kind == RelationKind::Link; None for inheritance relations.
This invariant is asserted in unit tests — the type does not enforce it
structurally.
target_data_model: Option<String>The target resource-type’s data-model name (the CURIE prefix of the
target’s @id). None when the target’s prefix is a system namespace
(knora-api, knora-base, etc.); Some(prefix) otherwise. The renderer
emits [to <dm>] iff Some(x) and x != DataModelStructure.data_model.
Mirrors Field.data_model (which tags the source direction for
cross-data-model fields). This invariant is asserted in unit tests.
is_builtin: boolBuiltin flag — semantics are asymmetric by kind:
Link→trueiff the link field’s CURIE prefix is a system namespace. A project-defined link field pointing to a built-in target isfalse(shown by default), because the field is project-defined.Inherits→trueiff the superclass (target) CURIE prefix is a system namespace (e.g.Resource,StillImageRepresentation).
The action filters !r.is_builtin by default; --include-builtins shows all.
Trait Implementations§
impl Eq for Relation
impl StructuralPartialEq for Relation
Auto Trait Implementations§
impl Freeze for Relation
impl RefUnwindSafe for Relation
impl Send for Relation
impl Sync for Relation
impl Unpin for Relation
impl UnsafeUnpin for Relation
impl UnwindSafe for Relation
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<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
key and return true if they are equal.