Skip to main content

compatible

Function compatible 

Source
pub fn compatible(riff: &Build, server: &Build) -> bool
Expand description

True when riff and riff-server can talk: riff is on a line that the server takes (Semver::riff_lines). That is the line of the server (01M3MX1DYY6AVDW946NR0B9T2C), or the line before (01M3MX1E1EY1M7JGNCN6FCEVQK). Each side checks the other with it: riff each reply, and riff-server each call.

use riff_core::build::{Build, compatible};

let b = |v: &str| Build { version: v.into(), ..Build::this() };
assert!(compatible(&b("0.4.0"), &b("0.4.3")));
assert!(compatible(&b("0.4.3"), &b("0.4.0")));
assert!(compatible(&b("0.3.2"), &b("0.4.0")));
assert!(!compatible(&b("0.4.0"), &b("0.3.2")));
assert!(!compatible(&b("0.2.0"), &b("0.4.0")));
assert!(compatible(&b("1.0.0"), &b("1.3.0")));
assert!(!compatible(&b("next"), &b("0.4.0")));

// The same rule with the version of this build: the line before
// talks, and two lines before do not.
let this = Build::this();
let line = this.semver().unwrap();
let before = line.line_before().unwrap();
assert!(compatible(&this, &this));
assert!(compatible(&b(&before.to_string()), &this));
assert!(!compatible(&b(&before.line_before().unwrap().to_string()), &this));
assert!(!compatible(&b(&line.line_after().to_string()), &this));