Cleanup code

next
Sayan Nandan 2 years ago
parent 2508e9b6df
commit ba17f0a0cd
No known key found for this signature in database
GPG Key ID: 8BC07A0A4D41DD52

@ -1,6 +1,6 @@
use clap::{ArgAction, Parser};
const HELP_TEMPLATE: &'static str = r#"
const HELP_TEMPLATE: &str = r#"
{before-help}{name} {version}
{author-with-newline}{about-with-newline}
{usage-heading} {usage}

@ -45,7 +45,7 @@ lazy_static::lazy_static! {
};
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum TokenizerError {
QuoteMismatch(String),
BacktickMismatch(String),

@ -37,7 +37,7 @@ use {
pub const BINARIES: [&str; 4] = ["skyd", "sky-bench", "skysh", "sky-migrate"];
/// The build mode
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum BuildMode {
Debug,
Release,

@ -35,7 +35,7 @@ use {
};
#[derive(Debug)]
#[cfg_attr(test, derive(PartialEq))]
#[cfg_attr(test, derive(PartialEq, Eq))]
#[repr(u8)]
/// A statement that can be executed
pub enum Statement {
@ -64,7 +64,7 @@ pub enum Statement {
pub type StatementLT<'a> = Life<'a, Statement>;
#[derive(Debug)]
#[cfg_attr(test, derive(PartialEq))]
#[cfg_attr(test, derive(PartialEq, Eq))]
pub enum Entity {
Current(RawSlice),
Full(RawSlice, RawSlice),
@ -78,7 +78,7 @@ impl Entity {
}
#[derive(Debug)]
#[cfg_attr(test, derive(PartialEq))]
#[cfg_attr(test, derive(PartialEq, Eq))]
/// The field configuration used when declaring the fields for a model
pub struct FieldConfig {
/// the types of the fields

@ -29,7 +29,7 @@ use crate::{
protocol::interface::ProtocolSpec,
};
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
#[repr(u8)]
/// BlueQL errors
pub enum LangError {

@ -33,7 +33,7 @@ use {
core::{marker::PhantomData, slice, str},
};
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
#[repr(u8)]
/// BQL tokens
pub enum Token {
@ -75,7 +75,7 @@ impl From<Type> for Token {
}
}
#[derive(Debug, PartialEq, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[repr(u8)]
/// BlueQL keywords
pub enum Keyword {
@ -90,7 +90,7 @@ pub enum Keyword {
Type(Type),
}
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
/// BlueQL types
pub enum Type {
@ -99,7 +99,7 @@ pub enum Type {
List,
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
/// Type expression (ty<ty<...>>)
pub struct TypeExpression(pub Vec<Type>);

@ -50,7 +50,7 @@ pub fn compile<'a>(src: &'a [u8], extra: usize) -> LangResult<Life<'a, Statement
}
#[cfg_attr(not(test), derive(Debug))]
#[cfg_attr(not(test), derive(PartialEq))]
#[cfg_attr(not(test), derive(PartialEq, Eq))]
pub struct RawSlice {
ptr: *const u8,
len: usize,
@ -72,6 +72,8 @@ impl PartialEq for RawSlice {
unsafe { self.as_slice() == other.as_slice() }
}
}
#[cfg(test)]
impl Eq for RawSlice {}
impl RawSlice {
const _ENSURE_ALIGN: () = assert!(mem::align_of::<RawSlice>() == mem::align_of::<&[u8]>());

@ -34,7 +34,7 @@ use {
};
/// This struct is an _object representation_ used for parsing the TOML file
#[derive(Deserialize, Debug, PartialEq)]
#[derive(Deserialize, Debug, PartialEq, Eq)]
pub struct Config {
/// The `server` key
pub(super) server: ConfigKeyServer,
@ -49,7 +49,7 @@ pub struct Config {
}
/// This struct represents the `server` key in the TOML file
#[derive(Deserialize, Debug, PartialEq)]
#[derive(Deserialize, Debug, PartialEq, Eq)]
pub struct ConfigKeyServer {
/// The host key is any valid IPv4/IPv6 address
pub(super) host: IpAddr,
@ -66,7 +66,7 @@ pub struct ConfigKeyServer {
}
/// The BGSAVE section in the config file
#[derive(Deserialize, Debug, PartialEq)]
#[derive(Deserialize, Debug, PartialEq, Eq)]
pub struct ConfigKeyBGSAVE {
/// Whether BGSAVE is enabled or not
///
@ -80,7 +80,7 @@ pub struct ConfigKeyBGSAVE {
}
/// The snapshot section in the TOML file
#[derive(Deserialize, Debug, PartialEq)]
#[derive(Deserialize, Debug, PartialEq, Eq)]
pub struct ConfigKeySnapshot {
/// After how many seconds should the snapshot be created
pub(super) every: u64,
@ -92,7 +92,7 @@ pub struct ConfigKeySnapshot {
pub(super) failsafe: Option<bool>,
}
#[derive(Deserialize, Debug, PartialEq)]
#[derive(Deserialize, Debug, PartialEq, Eq)]
pub struct KeySslOpts {
pub(super) key: String,
pub(super) chain: String,

@ -39,7 +39,7 @@ use {
///
/// If BGSAVE is enabled, then the duration (corresponding to `every`) is wrapped in the `Enabled`
/// variant. Otherwise, the `Disabled` variant is to be used
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub enum BGSave {
Enabled(u64),
Disabled,
@ -69,7 +69,7 @@ impl BGSave {
}
#[repr(u8)]
#[derive(Debug, PartialEq)]
#[derive(Debug, Eq, PartialEq)]
pub enum ProtocolVersion {
V1,
V2,
@ -119,7 +119,7 @@ impl<'de> Deserialize<'de> for ProtocolVersion {
/// A `ConfigurationSet` which can be used by main::check_args_or_connect() to bind
/// to a `TcpListener` and show the corresponding terminal output for the given
/// configuration
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct ConfigurationSet {
/// If `noart` is set to true, no terminal artwork should be displayed
pub noart: bool,
@ -196,7 +196,7 @@ impl ConfigurationSet {
/// and will not even activate the non-SSL socket
/// - `InsecureOnly` : This indicates that the server would only accept non-SSL connections
/// and will not even activate the SSL socket
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum PortConfig {
SecureOnly {
host: IpAddr,
@ -273,7 +273,7 @@ impl PortConfig {
}
}
#[derive(Deserialize, Debug, PartialEq)]
#[derive(Deserialize, Debug, PartialEq, Eq)]
pub struct SslOpts {
pub key: String,
pub chain: String,
@ -295,7 +295,7 @@ impl SslOpts {
}
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
/// The snapshot configuration
///
pub struct SnapshotPref {
@ -322,7 +322,7 @@ impl SnapshotPref {
}
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
/// Snapshotting configuration
///
/// The variant `Enabled` directly carries a `ConfigKeySnapshot` object that
@ -346,7 +346,7 @@ impl SnapshotConfig {
type RestoreFile = Option<String>;
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
/// The type of configuration:
/// - The default configuration
/// - A custom supplied configuration
@ -413,7 +413,7 @@ impl ConfigType {
}
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum Modeset {
Dev,
Prod,
@ -458,7 +458,7 @@ impl<'de> Deserialize<'de> for Modeset {
}
}
#[derive(Debug, PartialEq, Deserialize)]
#[derive(Debug, PartialEq, Eq, Deserialize)]
pub struct AuthSettings {
pub origin_key: Option<AuthkeyWrapper>,
}

@ -38,7 +38,7 @@ const EMSG_ENV: &str = "Environment";
const EMSG_PROD: &str = "Production mode";
const TAB: &str = " ";
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct FeedbackStack {
stack: Vec<String>,
feedback_type: &'static str,
@ -93,7 +93,7 @@ impl ops::DerefMut for FeedbackStack {
}
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct ErrorStack {
feedback: FeedbackStack,
}
@ -125,7 +125,7 @@ impl ops::DerefMut for ErrorStack {
}
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct WarningStack {
feedback: FeedbackStack,
}

@ -62,7 +62,7 @@ const DEFAULT_SSL_PORT: u16 = 2004;
type StaticStr = &'static str;
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct AuthkeyWrapper(pub Authkey);
impl AuthkeyWrapper {
@ -186,7 +186,7 @@ impl<'a, T: FromStr + 'a> TryFromConfigSource<T> for Result<String, VarError> {
}
}
#[derive(Debug, PartialEq, Default)]
#[derive(Debug, PartialEq, Eq, Default)]
/// Since we have conflicting trait implementations, we define a custom `Option<String>` type
pub struct OptString {
base: Option<String>,

@ -134,7 +134,7 @@ mod cluster {
}
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
/// Errors arising from trying to modify/access containers
#[allow(dead_code)]
pub enum DdlError {

@ -49,7 +49,7 @@ pub const LATEST_PROTOCOL_VERSION: f32 = Skyhash2::PROTOCOL_VERSION;
/// The latest protocol version supported by this version (`Skyhash-x.y`)
pub const LATEST_PROTOCOL_VERSIONSTRING: &str = Skyhash2::PROTOCOL_VERSIONSTRING;
#[derive(PartialEq)]
#[derive(PartialEq, Eq)]
/// As its name says, an [`UnsafeSlice`] is a terribly unsafe slice. It's guarantess are
/// very C-like, your ptr goes dangling -- and everything is unsafe.
///
@ -94,7 +94,7 @@ impl UnsafeSlice {
}
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
#[repr(u8)]
/// # Parser Errors
///

@ -92,7 +92,7 @@ pub struct SnapshotEngine {
remote_queue: QuickLock<HashSet<Box<[u8]>>>,
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum SnapshotActionResult {
Ok,
Busy,
@ -267,7 +267,7 @@ mod queue {
//! This implementation is specifically built for use with the snapshotting utility
use super::QStore;
use crate::corestore::iarray;
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct Queue {
queue: QStore,
maxlen: usize,

@ -136,7 +136,7 @@ impl<T: Clone> Clone for Wrapper<T> {
}
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
/// This is yet another compiler hack and has no "actual impact" in terms of memory alignment.
///
/// When it's hard to have a _split mutable borrow_, all across the source we use custom

@ -218,7 +218,7 @@ fn rcopy_okay() {
fs::remove_dir_all("my-backups").unwrap();
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum EntryKind {
Directory(String),
File(String),

@ -1,6 +1,6 @@
use clap::{ArgAction, Parser};
const HELP_TEMPLATE: &'static str = r#"
const HELP_TEMPLATE: &str = r#"
{before-help}{name} {version}
{author-with-newline}{about-with-newline}
{usage-heading} {usage}
@ -94,7 +94,7 @@ mod tests {
assert_eq!(cli.runs, 5);
assert_eq!(cli.kvsize, 3);
assert_eq!(cli.query_count, 100_000);
assert_eq!(cli.json, false);
assert!(!cli.json);
}
#[test]
@ -119,6 +119,6 @@ mod tests {
assert_eq!(cli.host, "devil");
assert_eq!(cli.port, 666);
assert_eq!(cli.json, true);
assert!(cli.json);
}
}

@ -59,5 +59,5 @@ fn run() -> error::BResult<()> {
// Run our task
bench::run_bench(server_config, bench_config)?;
util::cleanup(&server_config)
util::cleanup(server_config)
}

@ -1,6 +1,6 @@
use clap::Parser;
const HELP_TEMPLATE: &'static str = r#"
const HELP_TEMPLATE: &str = r#"
{before-help}{name} {version}
{author-with-newline}{about-with-newline}
{usage-heading} {usage}
@ -47,7 +47,7 @@ mod tests {
let cli = Cli::parse_from(args.into_iter());
assert_eq!(cli.new, "localhost:1234");
assert_eq!(cli.prevdir, "/tmp/skyd1");
assert_eq!(cli.serial, false);
assert!(!cli.serial);
}
#[test]
@ -63,7 +63,7 @@ mod tests {
let cli = Cli::parse_from(args.into_iter());
assert_eq!(cli.new, "localhost:1234");
assert_eq!(cli.prevdir, "/tmp/skyd1");
assert_eq!(cli.serial, true);
assert!(cli.serial);
}
#[test]

Loading…
Cancel
Save