reth_db_models/
client_version.rs1use reth_codecs::{add_arbitrary_tests, Compact};
4use serde::{Deserialize, Serialize};
5
6#[derive(Clone, Eq, PartialEq, Debug, Default, Serialize, Deserialize)]
8#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
9#[add_arbitrary_tests(compact)]
10pub struct ClientVersion {
11 pub version: String,
13 pub git_sha: String,
15 pub build_timestamp: String,
17}
18
19impl ClientVersion {
20 pub fn is_empty(&self) -> bool {
22 self.version.is_empty() && self.git_sha.is_empty() && self.build_timestamp.is_empty()
23 }
24}
25
26impl Compact for ClientVersion {
27 fn to_compact<B>(&self, buf: &mut B) -> usize
28 where
29 B: bytes::BufMut + AsMut<[u8]>,
30 {
31 self.version.to_compact(buf);
32 self.git_sha.to_compact(buf);
33 self.build_timestamp.to_compact(buf)
34 }
35
36 fn from_compact(buf: &[u8], len: usize) -> (Self, &[u8]) {
37 let (version, buf) = String::from_compact(buf, len);
38 let (git_sha, buf) = String::from_compact(buf, len);
39 let (build_timestamp, buf) = String::from_compact(buf, len);
40 let client_version = Self { version, git_sha, build_timestamp };
41 (client_version, buf)
42 }
43}