-
Notifications
You must be signed in to change notification settings - Fork 5.4k
/
shared.rs
62 lines (54 loc) · 1.48 KB
/
shared.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
/// This module is shared between build script and the binaries. Use it sparsely.
use deno_core::anyhow::bail;
use deno_core::error::AnyError;
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ReleaseChannel {
/// Stable version, eg. 1.45.4, 2.0.0, 2.1.0
#[allow(unused)]
Stable,
/// Pointing to a git hash
#[allow(unused)]
Canary,
/// Long term support release
#[allow(unused)]
Lts,
/// Release candidate, eg. 1.46.0-rc.0, 2.0.0-rc.1
#[allow(unused)]
Rc,
}
impl ReleaseChannel {
#[allow(unused)]
pub fn name(&self) -> &str {
match self {
Self::Stable => "stable",
Self::Canary => "canary",
Self::Rc => "release candidate",
Self::Lts => "long term support",
}
}
// NOTE(bartlomieju): do not ever change these values, tools like `patchver`
// rely on them.
#[allow(unused)]
pub fn serialize(&self) -> String {
match self {
Self::Stable => "stable",
Self::Canary => "canary",
Self::Rc => "rc",
Self::Lts => "lts",
}
.to_string()
}
// NOTE(bartlomieju): do not ever change these values, tools like `patchver`
// rely on them.
#[allow(unused)]
pub fn deserialize(str_: &str) -> Result<Self, AnyError> {
Ok(match str_ {
"stable" => Self::Stable,
"canary" => Self::Canary,
"rc" => Self::Rc,
"lts" => Self::Lts,
unknown => bail!("Unrecognized release channel: {}", unknown),
})
}
}