From 318413b119c5f0e988079bb7bede1a4a86583a7a Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 21 May 2020 23:42:27 -0400 Subject: use the crate version for the protocol version --- src/protocol.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/protocol.rs') diff --git a/src/protocol.rs b/src/protocol.rs index cf0c278..68506b2 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -1,4 +1,14 @@ -pub const VERSION: u32 = 3; +// eventually it would be nice to make this a const function so that we could +// just get the version from a variable directly, but this is fine for now +pub fn version() -> u32 { + let major = env!("CARGO_PKG_VERSION_MAJOR"); + let minor = env!("CARGO_PKG_VERSION_MINOR"); + let patch = env!("CARGO_PKG_VERSION_PATCH"); + + major.parse::().unwrap() * 1_000_000 + + minor.parse::().unwrap() * 1_000 + + patch.parse::().unwrap() +} #[derive(serde::Serialize, serde::Deserialize, Debug)] pub struct Request { -- cgit v1.2.3-54-g00ecf