coreos_stream_metadata/
fcos.rs

1//! APIs for interacting specifically with Fedora CoreOS
2
3use strum_macros::{Display, EnumString};
4
5/// Base URL to Fedora CoreOS streams metadata.
6pub const STREAM_BASE_URL: &str = "https://builds.coreos.fedoraproject.org/streams/";
7
8/// Well-known streams for Fedora CoreOS.
9///
10/// For more information, see https://docs.fedoraproject.org/en-US/fedora-coreos/update-streams/
11#[derive(Debug, PartialEq, Eq, Clone, Copy, EnumString, Display)]
12#[strum(serialize_all = "kebab-case")]
13pub enum StreamID {
14    /// The stable stream.
15    Stable,
16    /// The testing stream.
17    Testing,
18    /// The next stream.
19    Next,
20}
21
22impl StreamID {
23    /// Return the URL for this stream.
24    pub fn url(&self) -> String {
25        format!("{}{}.json", STREAM_BASE_URL, self)
26    }
27}
28
29#[cfg(test)]
30mod tests {
31    use std::str::FromStr;
32
33    use super::*;
34
35    #[test]
36    fn test_rhcos_streamid() {
37        assert_eq!(StreamID::Stable.to_string(), "stable");
38        assert_eq!(StreamID::from_str("testing").unwrap(), StreamID::Testing);
39        assert!(StreamID::from_str("foo").is_err());
40    }
41}