pub struct Edge {
pub direction: Direction,
pub edge: String,
pub field: String,
pub uri: Option<String>,
pub kind: String,
pub label: String,
pub title: Option<String>,
pub route: Option<String>,
pub external: bool,
}Expand description
One edge, as an entity page reads it.
Everything a reader needs about the other end is here — what to show, what kind of thing
it is, and the address to send them to — so the page renders a relation without going
back to the index for it. route is None exactly when external is true: a file, a
test or a command is named by the layer and is not an object of it, so there is no
entity page to link to and the template shows plain text instead of a dead link.
use majordomus_cli::entity::{Direction, Edge};
use majordomus_cli::order::Ordered;
let edge = Edge {
direction: Direction::Incoming,
edge: "depends_on".into(),
field: "depends_on".into(),
uri: Some("majordomus://rule/project.x@1".into()),
kind: "rule".into(),
label: "project.x@1".into(),
title: Some("A rule".into()),
route: Some("/cockpit/objects/rule/project-x-1".into()),
external: false,
};
// the relation is the group and the direction ranks inside it; see the `Ordered` impl
let key = edge.order_key();
assert_eq!(key.group, Some("depends_on"));
assert_eq!(key.rank, Direction::Incoming as i64);
assert_eq!(key.identity, "majordomus://rule/project.x@1");Fields§
§direction: DirectionWhich way it runs from the entity that was asked for.
edge: StringThe relationship, in the graph’s vocabulary (depends_on, put_in_force, …).
field: StringThe front matter key the reference was declared under.
uri: Option<String>The object at the other end: its URI when the layer holds it.
kind: StringIts kind — of the layer, or the external vocabulary (file, test, command).
label: StringWhat to show: the identity of an object, or the name of something outside.
title: Option<String>Its title, when it is an object that has one.
route: Option<String>Its entity route, when it has one; absent for something outside the layer.
external: boolTrue when the other end is not an object of this index.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Edge
impl<'de> Deserialize<'de> for Edge
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>,
impl Eq for Edge
Source§impl JsonSchema for Edge
impl JsonSchema for Edge
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Ordered for Edge
An edge is ordered by the relation it is, then by which way it runs, then by what a
reader sees.
impl Ordered for Edge
An edge is ordered by the relation it is, then by which way it runs, then by what a reader sees.
The relation is the group, because that is the bucket the reader is actually scanning —
every depends_on together, every put_in_force together — and the direction is a rank
inside it rather than the most significant part, because every consumer of this
collection filters to one direction before it renders (the entity page draws the
declared references and the backlinks as two sections). The URI is the tie-breaker, and
an external end that has none falls back to its label; edges dedups, so two edges that
compare equal here were the same edge twice.
This is the whole order of the collection. There was a sort_by here beside the
building of it, which is the second opinion crate::order exists to remove — the
natural comparison it brings is also the one every other surface of this repository
shows, so case-2 precedes case-10 on an entity page as it does everywhere else.
impl StructuralPartialEq for Edge
Auto Trait Implementations§
impl Freeze for Edge
impl RefUnwindSafe for Edge
impl Send for Edge
impl Sync for Edge
impl Unpin for Edge
impl UnsafeUnpin for Edge
impl UnwindSafe for Edge
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
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.