pub struct Build {
pub version: String,
pub commit: String,
pub time: String,
}Expand description
One build of riff: the crate version, the commit and its UTC time.
use riff_core::build::Build;
let b: Build = "0.4.1 929605821e54 2026-09-27T22:03:01Z".parse().unwrap();
assert_eq!(b.commit, "929605821e54");
assert_eq!(b.semver().unwrap().minor, 4);
assert_eq!(b.to_string(), "0.4.1 929605821e54 2026-09-27T22:03:01Z");
// A build of an older form, or with no semantic version, is not a build.
assert!("0.2.0 929605821e54 2026-09-27T22:03:01Z wire 1".parse::<Build>().is_err());
assert!("next 929605821e54 2026-09-27T22:03:01Z".parse::<Build>().is_err());Fields§
§version: StringThe crate version.
commit: StringThe last commit that changed the code.
time: StringThe time of that commit, in UTC.
Implementations§
Source§impl Build
impl Build
Sourcepub fn this() -> Build
pub fn this() -> Build
The build of this binary.
let me = riff_core::build::Build::this();
assert_eq!(me.version, env!("CARGO_PKG_VERSION"));
assert!(!me.commit.is_empty());Sourcepub fn from_header(value: Option<&[u8]>) -> Option<Build>
pub fn from_header(value: Option<&[u8]>) -> Option<Build>
The build that a reply or a request names in HEADER. None
when it names none, or names it in another form.
Sourcepub fn semver(&self) -> Option<Semver>
pub fn semver(&self) -> Option<Semver>
The semantic version of the build. None when the crate version
is not one.
Sourcepub fn matches(&self, other: &Build) -> bool
pub fn matches(&self, other: &Build) -> bool
True when the two are the same build: the same version and commit.
use riff_core::build::Build;
let a: Build = "0.4.0 aaaa 2026-09-27T10:00:00Z".parse().unwrap();
let b: Build = "0.4.0 bbbb 2026-09-27T11:00:00Z".parse().unwrap();
assert!(a.matches(&a.clone()));
assert!(!a.matches(&b));Sourcepub fn older_than(&self, other: &Build) -> bool
pub fn older_than(&self, other: &Build) -> bool
True when this build is older than other: a lower version, or
the same version from an older commit (01M514C19H3WQP1FSX9RBVSC69).
The times are UTC in one form, so their text has the order of
time. With no semantic version on a side, it is false.
use riff_core::build::Build;
let b = |s: &str| s.parse::<Build>().unwrap();
let server = b("1.4.0 122daab96637 2026-10-15T23:08:34Z");
assert!(b("1.3.1 aaaa 2026-10-14T10:00:00Z").older_than(&server));
assert!(b("1.4.0 bbbb 2026-10-15T20:00:00Z").older_than(&server));
assert!(!server.older_than(&server));
assert!(!b("1.4.0 cccc 2026-10-16T01:00:00Z").older_than(&server));
// A higher version from an older commit is not older.
assert!(!b("1.5.0 dddd 2026-10-01T00:00:00Z").older_than(&server));Trait Implementations§
impl Eq for Build
impl StructuralPartialEq for Build
Auto Trait Implementations§
impl Freeze for Build
impl RefUnwindSafe for Build
impl Send for Build
impl Sync for Build
impl Unpin for Build
impl UnsafeUnpin for Build
impl UnwindSafe for Build
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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.