[][src]Struct exonum::runtime::versioning::ArtifactReq

#[non_exhaustive]pub struct ArtifactReq {
    pub name: String,
    pub version: VersionReq,
}

Requirement on an artifact. Can be matched against artifact identifiers.

Examples

// Requirements can be parsed from a string.
let req: ArtifactReq = "some.Service@^1.3.0".parse()?;

let valid_artifact = ArtifactId::new(
    RuntimeIdentifier::Rust as u32,
    "some.Service".to_owned(),
    "1.5.7".parse()?,
)?;
assert!(req.try_match(&valid_artifact).is_ok());

// This artifact is outdated.
let mut outdated_artifact = valid_artifact.clone();
outdated_artifact.version = "1.2.0".parse()?;
assert!(req.try_match(&outdated_artifact).is_err());

// This artifact is too new.
let mut novel_artifact = valid_artifact.clone();
novel_artifact.version = "2.0.0".parse()?;
assert!(req.try_match(&novel_artifact).is_err());

// This artifact has wrong name.
let mut other_artifact = valid_artifact.clone();
other_artifact.name = "other.Service".to_owned();
assert!(req.try_match(&novel_artifact).is_err());

Fields (Non-exhaustive)

Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
name: String

Artifact name.

version: VersionReq

Allowed artifact versions.

Methods

impl ArtifactReq[src]

pub fn new(name: impl Into<String>, version: VersionReq) -> Self[src]

Creates a new artifact requirement.

pub fn try_match(&self, artifact: &ArtifactId) -> Result<(), ArtifactReqError>[src]

Tries to match this requirement against the provided artifact.

Trait Implementations

impl Clone for ArtifactReq[src]

impl Debug for ArtifactReq[src]

impl Display for ArtifactReq[src]

impl FromStr for ArtifactReq[src]

type Err = Error

The associated error which can be returned from parsing.

impl PartialEq<ArtifactReq> for ArtifactReq[src]

impl StructuralPartialEq for ArtifactReq[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,