clone_solana_version/
legacy.rs1use {
2 crate::compute_commit,
3 clone_solana_sanitize::Sanitize,
4 serde_derive::{Deserialize, Serialize},
5 std::{convert::TryInto, fmt},
6};
7
8#[cfg_attr(feature = "frozen-abi", derive(AbiExample))]
10#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
11pub struct LegacyVersion1 {
12 major: u16,
13 minor: u16,
14 patch: u16,
15 commit: Option<u32>, }
17
18impl Sanitize for LegacyVersion1 {}
19
20#[cfg_attr(feature = "frozen-abi", derive(AbiExample))]
21#[derive(Serialize, Deserialize, Clone, PartialEq, Eq)]
22pub struct LegacyVersion2 {
23 pub major: u16,
24 pub minor: u16,
25 pub patch: u16,
26 pub commit: Option<u32>, pub feature_set: u32, }
29
30impl Default for LegacyVersion2 {
31 fn default() -> Self {
32 let feature_set = u32::from_le_bytes(
33 clone_agave_feature_set::ID.as_ref()[..4]
34 .try_into()
35 .unwrap(),
36 );
37 Self {
38 major: env!("CARGO_PKG_VERSION_MAJOR").parse().unwrap(),
39 minor: env!("CARGO_PKG_VERSION_MINOR").parse().unwrap(),
40 patch: env!("CARGO_PKG_VERSION_PATCH").parse().unwrap(),
41 commit: compute_commit(option_env!("CI_COMMIT")),
42 feature_set,
43 }
44 }
45}
46
47impl fmt::Debug for LegacyVersion2 {
48 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
49 write!(
50 f,
51 "{}.{}.{} (src:{}; feat:{})",
52 self.major,
53 self.minor,
54 self.patch,
55 match self.commit {
56 None => "devbuild".to_string(),
57 Some(commit) => format!("{commit:08x}"),
58 },
59 self.feature_set,
60 )
61 }
62}
63
64impl Sanitize for LegacyVersion2 {}