From a279456c548781921cb4aed8cc1bab68c74fb37b Mon Sep 17 00:00:00 2001 From: Sayan Nandan Date: Fri, 5 Apr 2024 12:46:47 +0530 Subject: [PATCH] config: Do not expose protocol primitives It doesn't look like a good idea to do this because of potential complications (and, why'd we want to allow it anyway?) --- CHANGELOG.md | 2 +- src/config.rs | 15 ++------------- src/protocol/handshake.rs | 4 ++-- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aabe50e..9d4ce40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ All changes in this project will be noted in this file. > - **Minimum Supported Skytable Version**: 0.8.2 > - **Field change warnings**: -> - The `Config` struct now has two additional fields. This is not a breaking change because the functionality of the library remains unchanged +> - The `Config` struct now has one additional field. This is not a breaking change because the functionality of the library remains unchanged - Added support for pipelines diff --git a/src/config.rs b/src/config.rs index b818f68..51f3078 100644 --- a/src/config.rs +++ b/src/config.rs @@ -30,7 +30,7 @@ //! let mut db = Config::new("subnetx2_db1", 2008, "username", "password").connect().unwrap(); //! ``` -pub use crate::protocol::handshake::ProtocolVersion; +use crate::protocol::handshake::ProtocolVersion; /// The default host /// @@ -48,8 +48,7 @@ pub struct Config { port: u16, username: Box, password: Box, - protocol: ProtocolVersion, - pub(crate) protocol_changed: bool, + pub(crate) protocol: ProtocolVersion, } impl Config { @@ -66,7 +65,6 @@ impl Config { username, password, protocol, - protocol_changed: false, } } /// Create a new [`Config`] using the default connection settings and using the provided username and password @@ -101,13 +99,4 @@ impl Config { pub fn password(&self) -> &str { self.password.as_ref() } - /// Set the protocol - pub fn set_protocol(&mut self, protocol: ProtocolVersion) { - self.protocol_changed = true; - self.protocol = protocol; - } - /// Returns the protocol used for connections - pub fn protocol(&self) -> ProtocolVersion { - self.protocol - } } diff --git a/src/protocol/handshake.rs b/src/protocol/handshake.rs index 05f62a7..35a02e7 100644 --- a/src/protocol/handshake.rs +++ b/src/protocol/handshake.rs @@ -22,7 +22,7 @@ use crate::{ #[derive(Debug, PartialEq, Clone, Copy)] #[repr(u8)] /// The Skyhash protocol version -pub enum ProtocolVersion { +pub(crate) enum ProtocolVersion { /// Skyhash 2.0 V2_0, } @@ -38,7 +38,7 @@ impl ProtocolVersion { pub struct ClientHandshake(Box<[u8]>); impl ClientHandshake { pub(crate) fn new(cfg: &Config) -> Self { - Self::_new(cfg.protocol().hs_block(), cfg) + Self::_new(cfg.protocol.hs_block(), cfg) } fn _new(hs: [u8; 6], cfg: &Config) -> Self { let mut v = Vec::with_capacity(6 + cfg.username().len() + cfg.password().len() + 5);