Skip to main content

EdgePolicy

Struct EdgePolicy 

Source
pub struct EdgePolicy {
    pub kind: &'static str,
    pub forward: f64,
    pub reverse: f64,
    pub forward_reason: &'static str,
    pub reverse_reason: &'static str,
}
Expand description

Which way an edge is worth following, and what it means in each direction.

An edge of the composed graph has one kind and two readings, and the two are rarely worth the same. From an issue, the milestone it belongs_to is strong context; from the milestone, any one of its thirty-three issues is weak. So the weight is per direction, and so is the reason — which is prose a reader of the answer sees, not a comment here.

A weight is a multiplier on the relevance of the entry the edge was followed from, so relevance decays with distance and the rate of decay is the edge’s own rather than a global constant.

use majordomus_cli::devcontext::{edge_policy, EdgePolicy};

// `belongs_to` is asymmetric, and the asymmetry is the point
let belongs_to: &EdgePolicy = edge_policy("belongs_to").unwrap();
assert!(
    belongs_to.forward > belongs_to.reverse,
    "an issue's milestone is context; a milestone's every issue is not",
);
assert_ne!(belongs_to.forward_reason, belongs_to.reverse_reason);

// `supersedes` is symmetric: either version is context for the other
let supersedes: &EdgePolicy = edge_policy("supersedes").unwrap();
assert_eq!(supersedes.forward, supersedes.reverse);

// and both readings of every followed kind carry words a reader of the answer sees
for kind in ["depends_on", "governed_by", "tested_by"] {
    let e = edge_policy(kind).unwrap();
    assert!(!e.forward_reason.is_empty() && !e.reverse_reason.is_empty(), "{kind}");
}

Fields§

§kind: &'static str

The edge kind, as the composed graph names it.

§forward: f64

Relevance multiplier when followed from source to target; 0.0 to refuse.

§reverse: f64

Relevance multiplier when followed from target to source; 0.0 to refuse.

§forward_reason: &'static str

Why the target is context for the source.

§reverse_reason: &'static str

Why the source is context for the target.

Trait Implementations§

Source§

impl Clone for EdgePolicy

Source§

fn clone(&self) -> EdgePolicy

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 Copy for EdgePolicy

Source§

impl Debug for EdgePolicy

Source§

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

Formats the value using the given formatter. Read more

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
§

impl<T> AsOut<T> for T
where T: Copy,

§

fn as_out(&mut self) -> Out<'_, T>

Returns an out reference to self.
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> 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