Skip to main content

Build

Struct Build 

Source
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: String

The crate version.

§commit: String

The last commit that changed the code.

§time: String

The time of that commit, in UTC.

Implementations§

Source§

impl Build

Source

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

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.

Source

pub fn semver(&self) -> Option<Semver>

The semantic version of the build. None when the crate version is not one.

Source

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));
Source

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§

Source§

impl Clone for Build

Source§

fn clone(&self) -> Build

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 Build

Source§

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

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

impl Display for Build

Source§

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

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

impl FromStr for Build

Source§

type Err = String

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, String>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Build

Source§

fn eq(&self, other: &Build) -> 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 Build

Source§

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> 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.