Skip to main content

Mismatch

Struct Mismatch 

Source
pub struct Mismatch {
    pub riff: Option<Build>,
    pub server: Option<Build>,
    pub seen: Option<String>,
}
Expand description

riff and its riff-server cannot talk (01M3MX1E65XGWDZ062PQ9YXQ5T). None is a side that sent no build, or a build of an older form.

Fields§

§riff: Option<Build>

The build of riff.

§server: Option<Build>

The build of riff-server.

§seen: Option<String>

What riff saw of a reply that named no build: its status and URL, for example status 200 OK from http://127.0.0.1:7878/v1/who (01M3QCMJ9F1GRTRRSB4AW9TC3D). None on the side of the server.

Implementations§

Source§

impl Mismatch

Source

pub fn older(&self) -> Side

The side to update: the older version. A side with no build is older.

use riff_core::build::{Build, Mismatch, Side};

let b = |v: &str| Some(Build { version: v.into(), ..Build::this() });
let m = |riff, server| Mismatch { riff, server, seen: None }.older();
assert_eq!(m(b("0.2.0"), b("0.4.0")), Side::Riff);
assert_eq!(m(b("0.4.0"), b("0.3.2")), Side::Server);
assert_eq!(m(b("0.4.0"), None), Side::Server);
assert_eq!(m(None, b("0.4.0")), Side::Riff);

Trait Implementations§

Source§

impl Clone for Mismatch

Source§

fn clone(&self) -> Mismatch

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Mismatch

Source§

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

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

impl Display for Mismatch

Source§

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

use riff_core::build::{Build, Mismatch, UPDATE_URL};

// A riff two lines before this server.
let server = Build::this();
let line = server.semver().unwrap();
let before = line.line_before().unwrap();
let two = Build {
    version: before.line_before().unwrap().to_string(),
    ..Build::this()
};
let m = Mismatch { riff: Some(two.clone()), server: Some(server.clone()), seen: None };
assert_eq!(
    m.to_string(),
    format!(
        "this riff ({two}) and its riff-server ({server}) do not match. riff-server {} \
         talks only with riff {} and {}. Update riff on this machine, then start your \
         sessions again. See {UPDATE_URL}",
        line.line(),
        line.line(),
        before.line()
    )
);
let old = Mismatch { riff: m.riff.clone(), server: None, seen: None };
assert!(old.to_string().contains("riff-server (an older build)"), "{old}");
assert!(old.to_string().contains("Update riff-server"), "{old}");
// riff names what it saw of a reply with no build.
let seen = Some("status 200 OK from http://127.0.0.1:7878/v1/who".to_string());
let old = Mismatch { seen, ..old };
assert!(
    old.to_string().contains(
        "its riff-server (no riff build in the reply: status 200 OK from \
         http://127.0.0.1:7878/v1/who) do not match"
    ),
    "{old}"
);
Source§

impl Error for Mismatch

1.30.0 · Source§

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

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for Mismatch

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Eq for Mismatch

Source§

impl StructuralPartialEq for Mismatch

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
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 ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.