pub enum RefusalCode {
Show 14 variants
Malformed,
Oversized,
ProtocolUnsupported,
Signature,
Stale,
Replay,
RepositoryMismatch,
Untrusted,
SelfLink,
NotActive,
UnknownLink,
Capacity,
FeatureUnsupported,
Misaddressed,
}Expand description
Why a link message was turned down. Every refusal is typed, counted and shown: a mesh that refuses a peer says which rule did, instead of dropping a socket.
The codes are the diagnosis a person needs when two runtimes will not link, and they
are deliberately distinct where the remedies differ: Untrusted is a key to add,
RepositoryMismatch is two different repositories, SelfLink is a configuration that
dials its own endpoint, and UnknownLink is not a failure at all but an instruction to
say hello again.
use majordomus_cli::mesh::link::RefusalCode;
// the wire word is the code's identity across surfaces, and it is stable
assert_eq!(RefusalCode::RepositoryMismatch.as_str(), "repository_mismatch");
assert_eq!(
serde_json::to_value(RefusalCode::Untrusted).unwrap(),
serde_json::json!("untrusted"),
);
assert_ne!(RefusalCode::Untrusted, RefusalCode::RepositoryMismatch);Variants§
Malformed
Not the shape of the message.
Oversized
Over MAX_LINK_MESSAGE.
ProtocolUnsupported
The protocol ranges do not meet.
Signature
The signature does not verify.
Stale
The timestamp is outside the skew window.
Replay
A nonce or a counter already seen.
RepositoryMismatch
The peer serves another repository: the isolation rule.
Untrusted
The peer’s key is not trusted by this runtime’s policy: discovery is not trust.
SelfLink
The peer is this very runtime.
NotActive
This runtime’s cooperation is not active.
UnknownLink
The link id is unknown here: the answerer restarted or expired the link; say hello.
Capacity
A bound of this runtime is full.
FeatureUnsupported
The peer lacks a feature the operation needs.
Misaddressed
A hello addressed to another runtime: captured on its way there and replayed here.
Implementations§
Source§impl RefusalCode
impl RefusalCode
Sourcepub fn as_str(self) -> &'static str
pub fn as_str(self) -> &'static str
The code’s wire word: the snake-case spelling every surface uses, so a refusal reads the same in a log line, a JSON answer and a peer’s counters. It is written out here rather than derived from the variant name, because the word is protocol and renaming a variant must not silently change what another runtime reads.
use majordomus_cli::mesh::link::RefusalCode;
assert_eq!(RefusalCode::ProtocolUnsupported.as_str(), "protocol_unsupported");
assert_eq!(RefusalCode::SelfLink.as_str(), "self_link");
assert_eq!(
serde_json::to_value(RefusalCode::SelfLink).unwrap(),
serde_json::json!(RefusalCode::SelfLink.as_str()),
"one spelling, whichever surface prints it",
);Trait Implementations§
Source§impl Clone for RefusalCode
impl Clone for RefusalCode
Source§fn clone(&self) -> RefusalCode
fn clone(&self) -> RefusalCode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RefusalCode
Source§impl Debug for RefusalCode
impl Debug for RefusalCode
Source§impl<'de> Deserialize<'de> for RefusalCode
impl<'de> Deserialize<'de> for RefusalCode
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 RefusalCode
Source§impl JsonSchema for RefusalCode
impl JsonSchema for RefusalCode
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 Ord for RefusalCode
impl Ord for RefusalCode
Source§fn cmp(&self, other: &RefusalCode) -> Ordering
fn cmp(&self, other: &RefusalCode) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for RefusalCode
impl PartialEq for RefusalCode
Source§fn eq(&self, other: &RefusalCode) -> bool
fn eq(&self, other: &RefusalCode) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for RefusalCode
impl PartialOrd for RefusalCode
Source§impl Serialize for RefusalCode
impl Serialize for RefusalCode
impl StructuralPartialEq for RefusalCode
Auto Trait Implementations§
impl Freeze for RefusalCode
impl RefUnwindSafe for RefusalCode
impl Send for RefusalCode
impl Sync for RefusalCode
impl Unpin for RefusalCode
impl UnsafeUnpin for RefusalCode
impl UnwindSafe for RefusalCode
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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.