wasm_pkg_client/
release.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use std::cmp::Ordering;

use wasm_pkg_common::{digest::ContentDigest, package::Version};

/// Package release details.
///
/// Returned by [`crate::Client::get_release`] and passed to
/// [`crate::Client::stream_content`].
#[derive(Clone, Debug)]
pub struct Release {
    pub version: Version,
    pub content_digest: ContentDigest,
}

#[derive(Clone, Debug, Eq)]
pub struct VersionInfo {
    pub version: Version,
    pub yanked: bool,
}

impl Ord for VersionInfo {
    fn cmp(&self, other: &Self) -> Ordering {
        self.version.cmp(&other.version)
    }
}

impl PartialOrd for VersionInfo {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.version.cmp(&other.version))
    }
}

impl PartialEq for VersionInfo {
    fn eq(&self, other: &Self) -> bool {
        self.version == other.version
    }
}

impl std::fmt::Display for VersionInfo {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{version}", version = self.version)
    }
}