Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 15 additions & 47 deletions crates/rust-release/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@
#![deny(unsafe_code)]
#![deny(missing_docs)]

use crate::toolchain::ReleaseToolchain;

/// Describes toolchains in so far they're relevant to a release
pub mod toolchain;

/// Describes the version of a release
pub mod version;

/// Type to model a Rust release.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct RustRelease {
version: ReleaseVersion,
release_date: Option<rust_toolchain::Date>,
toolchains: Vec<ExtendedToolchain>,
toolchains: Vec<ReleaseToolchain>,
}

impl RustRelease {
Expand All @@ -30,7 +38,7 @@ impl RustRelease {
pub fn new(
version: ReleaseVersion,
release_date: Option<rust_toolchain::Date>,
toolchains: impl IntoIterator<Item = ExtendedToolchain>,
toolchains: impl IntoIterator<Item = ReleaseToolchain>,
) -> Self {
Self {
version,
Expand All @@ -50,7 +58,7 @@ impl RustRelease {
}

/// Toolchains associated with the release
pub fn toolchains(&self) -> impl Iterator<Item = &ExtendedToolchain> {
pub fn toolchains(&self) -> impl Iterator<Item = &ReleaseToolchain> {
self.toolchains.iter()
}
}
Expand All @@ -69,46 +77,6 @@ pub enum ReleaseVersion {
Nightly(rust_toolchain::channel::Nightly),
}

/// Type to model a Rust toolchain, with additional metadata relevant to a
/// release.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ExtendedToolchain {
toolchain: rust_toolchain::Toolchain,
tier: TargetTier,
}

impl ExtendedToolchain {
/// Create an ExtendedToolchain from a rust_toolchain::Toolchain
pub fn new(toolchain: rust_toolchain::Toolchain, tier: TargetTier) -> Self {
Self { toolchain, tier }
}

/// Get the toolchain
pub fn toolchain(&self) -> &rust_toolchain::Toolchain {
&self.toolchain
}

/// Get the toolchain tier
pub fn tier(&self) -> TargetTier {
self.tier
}
}

/// Support tier for a target
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub enum TargetTier {
/// Tier 1 target
T1,
/// Tier 2 target
T2,
/// Tier 2.5 target
T2_5,
/// Tier 3 target
T3,
/// Tier is unknown
Unknown,
}

#[cfg(test)]
mod tests {
use super::*;
Expand All @@ -124,15 +92,15 @@ mod tests {
let release = RustRelease::new(
version,
None,
vec![ExtendedToolchain::new(
vec![ReleaseToolchain::new(
rust_toolchain::Toolchain::new(
rust_toolchain::Channel::Stable(stable_version.clone()),
None,
rust_toolchain::Target::host(),
HashSet::new(),
HashSet::new(),
),
TargetTier::Unknown,
toolchain::TargetTier::Unknown,
)],
);

Expand All @@ -153,15 +121,15 @@ mod tests {
let release = RustRelease::new(
version,
date.clone(),
vec![ExtendedToolchain::new(
vec![ReleaseToolchain::new(
rust_toolchain::Toolchain::new(
rust_toolchain::Channel::Stable(stable_version.clone()),
date,
rust_toolchain::Target::host(),
HashSet::new(),
HashSet::new(),
),
TargetTier::Unknown,
toolchain::TargetTier::Unknown,
)],
);

Expand Down
41 changes: 41 additions & 0 deletions crates/rust-release/src/toolchain.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//! Types for working with Rust toolchains in so far they're relevant to a Rust release.

/// Type to model a Rust toolchain, with additional metadata relevant to a
/// release.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ReleaseToolchain {
toolchain: rust_toolchain::Toolchain,
tier: TargetTier,
}

impl ReleaseToolchain {
/// Create an ExtendedToolchain from a rust_toolchain::Toolchain
pub fn new(toolchain: rust_toolchain::Toolchain, tier: TargetTier) -> Self {
Self { toolchain, tier }
}

/// Get the toolchain
pub fn toolchain(&self) -> &rust_toolchain::Toolchain {
&self.toolchain
}

/// Get the toolchain tier
pub fn tier(&self) -> TargetTier {
self.tier
}
}

/// Support tier for a target
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub enum TargetTier {
/// Tier 1 target
T1,
/// Tier 2 target
T2,
/// Tier 2.5 target
T2_5,
/// Tier 3 target
T3,
/// Tier is unknown
Unknown,
}
15 changes: 15 additions & 0 deletions crates/rust-release/src/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! Version information for a Rust release.

/// A combination of a channel and the version number.
///
/// For stable and beta releases, we have a three component MAJOR.MINOR.PATCH
/// version number. For nightly releases, we have a release date.
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum ReleaseVersion {
/// A stable channel release version
Stable(rust_toolchain::channel::Stable),
/// A beta channel release version
Beta(rust_toolchain::channel::Beta),
/// A nightly channel release version
Nightly(rust_toolchain::channel::Nightly),
}
Loading