pub enum CooperationError {
Conflict(Vec<ClaimView>),
NotOwn(String),
NotFound(String),
FeatureUnsupported(String),
Invalid(String),
}Expand description
Why a cooperation operation did not happen. Every variant is a decision rather than a fault: nothing here is a transport failure or a bug, so a caller that sees one has been told something true about the mesh and should say it to its user rather than retry.
Conflict carries the claims it met instead of a message about them, because the
worker being refused needs the other side’s scope, session and runtime to go and talk
to whoever holds it.
use majordomus_cli::mesh::cooperation::CooperationError;
use majordomus_cli::mesh::journal::{ClaimMode, SessionInfo};
let held = SessionInfo::named("s1", "cli");
cooperation.claim(&held, vec!["apps".into()], None, ClaimMode::Exclusive, None).unwrap();
let latecomer = SessionInfo::named("s2", "cli");
let refused = cooperation
.claim(&latecomer, vec!["apps/cli".into()], None, ClaimMode::Exclusive, None)
.unwrap_err();
match &refused {
CooperationError::Conflict(claims) => assert_eq!(claims[0].scope, ["apps"]),
other => panic!("expected a conflict, got {other}"),
}
assert!(refused.to_string().contains("apps"), "the message names what it met");Variants§
Conflict(Vec<ClaimView>)
An exclusive claim meets live exclusive claims of other sessions.
NotOwn(String)
The operation needs something this runtime wrote, and this was written elsewhere.
NotFound(String)
Nothing by that name.
FeatureUnsupported(String)
The peer lacks a feature the operation needs.
Invalid(String)
Out of bounds.
Trait Implementations§
Source§impl Clone for CooperationError
impl Clone for CooperationError
Source§fn clone(&self) -> CooperationError
fn clone(&self) -> CooperationError
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 CooperationError
impl Debug for CooperationError
Source§impl Display for CooperationError
impl Display for CooperationError
Source§impl Error for CooperationError
impl Error for CooperationError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for CooperationError
impl RefUnwindSafe for CooperationError
impl Send for CooperationError
impl Sync for CooperationError
impl Unpin for CooperationError
impl UnsafeUnpin for CooperationError
impl UnwindSafe for CooperationError
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