Skip to content

Commit

Permalink
config: Do not expose protocol primitives
Browse files Browse the repository at this point in the history
It doesn't look like a good idea to do this because of potential
complications (and, why'd we want to allow it anyway?)
  • Loading branch information
ohsayan committed Apr 5, 2024
1 parent 33b7993 commit 825703c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Expand Up @@ -2,12 +2,12 @@

All changes in this project will be noted in this file.

### 0.9.0 (unreleased)
### 0.8.7 (unreleased)

> **BREAKING PATCH DUE TO MINIMUM VERSION UPGRADE**
> - **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

### 0.8.6
Expand Down
15 changes: 2 additions & 13 deletions src/config.rs
Expand Up @@ -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
///
Expand All @@ -48,8 +48,7 @@ pub struct Config {
port: u16,
username: Box<str>,
password: Box<str>,
protocol: ProtocolVersion,
pub(crate) protocol_changed: bool,
pub(crate) protocol: ProtocolVersion,
}

impl Config {
Expand All @@ -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
Expand Down Expand Up @@ -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
}
}
4 changes: 2 additions & 2 deletions src/protocol/handshake.rs
Expand Up @@ -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,
}
Expand All @@ -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);
Expand Down

0 comments on commit 825703c

Please sign in to comment.