Skip to main content

EdgeRule

Struct EdgeRule 

Source
pub struct EdgeRule {
    pub edge: String,
    pub means: String,
    pub forward: Option<f64>,
    pub reverse: Option<f64>,
    pub reason: String,
    pub refused: bool,
}
Expand description

One edge of the composed graph, and what the compiler does with it.

Every edge kind the graph declares gets a row, followed or not, which is the property that makes this projection worth reading: an edge added to the graph and not to the traversal table appears here as refused with a reason saying the compiler has no rule for it, rather than being silently unfollowed. A table that only listed the edges it followed could not tell you what it was ignoring.

forward and reverse are absent rather than zero when the edge is not followed that way, so “not followed” is one representation and not two. means is the graph’s own account of the relation; reason is this compiler’s account of why it is or is not context, in both directions.

use majordomus_cli::devcontext::{edge_policy, policy, EdgeRule};
use majordomus_cli::synthetic::SyntheticRepository;

let repo = SyntheticRepository::small().unwrap();
let ctx = repo.context().unwrap();
let rules = policy(&ctx).unwrap();

// one row per edge kind the graph declares, followed or refused
let edges: &[EdgeRule] = &rules.edges;
assert!(!edges.is_empty(), "the graph declares edges");
for e in edges {
    // the row always says what the relation is and what was decided about it
    assert!(!e.means.is_empty() && !e.reason.is_empty(), "{}", e.edge);

    if e.refused {
        // not followed in either direction, and absent rather than zero
        assert!(e.forward.is_none() && e.reverse.is_none(), "{}", e.edge);
        assert!(edge_policy(&e.edge).is_none(), "{} is refused and in the table", e.edge);
    } else {
        // followed at least one way, at a weight the table declares
        assert!(e.forward.is_some() || e.reverse.is_some(), "{}", e.edge);
        let p = edge_policy(&e.edge).expect("a followed edge has a policy");
        assert_eq!(e.forward, (p.forward > 0.0).then_some(p.forward));
        assert_eq!(e.reverse, (p.reverse > 0.0).then_some(p.reverse));
    }
}

Fields§

§edge: String

The edge kind, as the composed graph names it.

§means: String

What the graph asserts by it.

§forward: Option<f64>

The relevance multiplier when followed source to target; absent when refused.

§reverse: Option<f64>

The multiplier when followed target to source; absent when refused.

§reason: String

Why the target is context for the source, or why the edge is refused.

§refused: bool

True when the compiler will not follow it in either direction.

Trait Implementations§

Source§

impl Clone for EdgeRule

Source§

fn clone(&self) -> EdgeRule

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EdgeRule

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for EdgeRule

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for EdgeRule

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for EdgeRule

Source§

fn eq(&self, other: &EdgeRule) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for EdgeRule

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for EdgeRule

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more