pub struct LinkRefusal {
pub code: RefusalCode,
pub detail: String,
pub proto_min: u32,
pub proto_max: u32,
}Expand description
A refusal: the code, the reason in words, and the protocol range of the refuser so a version mismatch is diagnosable from either end.
Carrying the refuser’s protocol range in every refusal, not only in the one about protocols, is what makes a version problem visible from the side that has the log: the dialer sees what the answerer speaks without anyone having to read the other machine.
use majordomus_cli::mesh::link::{LinkRefusal, RefusalCode, LINK_PROTOCOL_MAX};
let refusal = LinkRefusal::new(RefusalCode::Untrusted, "the key is not in the allowlist");
assert_eq!(refusal.code, RefusalCode::Untrusted);
assert_eq!(refusal.proto_max, LINK_PROTOCOL_MAX);
assert_eq!(refusal.to_string(), "untrusted: the key is not in the allowlist");Fields§
§code: RefusalCodeThe rule that refused.
detail: StringWhy, in words.
proto_min: u32The refuser’s oldest protocol.
proto_max: u32The refuser’s newest protocol.
Implementations§
Source§impl LinkRefusal
impl LinkRefusal
Sourcepub fn new(code: RefusalCode, detail: impl Into<String>) -> Self
pub fn new(code: RefusalCode, detail: impl Into<String>) -> Self
A refusal with this executable’s protocol range. Every refusal is built here rather than by hand, so that no call site can forget the range and leave the other end guessing whether it was turned down over a version or over a rule.
use majordomus_cli::mesh::link::{LinkRefusal, RefusalCode, LINK_PROTOCOL_MAX,
LINK_PROTOCOL_MIN};
let refusal = LinkRefusal::new(RefusalCode::Capacity, "256 peers already linked");
assert_eq!((refusal.proto_min, refusal.proto_max), (LINK_PROTOCOL_MIN, LINK_PROTOCOL_MAX));
assert_eq!(refusal.detail, "256 peers already linked");Trait Implementations§
Source§impl Clone for LinkRefusal
impl Clone for LinkRefusal
Source§fn clone(&self) -> LinkRefusal
fn clone(&self) -> LinkRefusal
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LinkRefusal
impl Debug for LinkRefusal
Source§impl<'de> Deserialize<'de> for LinkRefusal
impl<'de> Deserialize<'de> for LinkRefusal
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for LinkRefusal
impl Display for LinkRefusal
impl Eq for LinkRefusal
Source§impl JsonSchema for LinkRefusal
impl JsonSchema for LinkRefusal
Source§fn schema_id() -> Cow<'static, str>
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
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
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 moreSource§impl PartialEq for LinkRefusal
impl PartialEq for LinkRefusal
Source§fn eq(&self, other: &LinkRefusal) -> bool
fn eq(&self, other: &LinkRefusal) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for LinkRefusal
impl Serialize for LinkRefusal
impl StructuralPartialEq for LinkRefusal
Auto Trait Implementations§
impl Freeze for LinkRefusal
impl RefUnwindSafe for LinkRefusal
impl Send for LinkRefusal
impl Sync for LinkRefusal
impl Unpin for LinkRefusal
impl UnsafeUnpin for LinkRefusal
impl UnwindSafe for LinkRefusal
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,
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
Compare self to
key and return true if they are equal.