Skip to content
This repository was archived by the owner on Jul 11, 2021. It is now read-only.

Commit 9e0a493

Browse files
authored
Merge pull request #74 from RedBeardLab/2018_edition
2018 edition
2 parents a552f02 + d975edb commit 9e0a493

12 files changed

Lines changed: 70 additions & 44 deletions

File tree

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "rediSQL"
33
version = "1.0.3-rc02"
44
authors = ["Simone Mosciatti <simone@redbeardlab.tech>"]
5+
edition = "2018"
56

67
[lib]
78
name = "redis_sql"

redisql_lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "redisql_lib"
33
version = "0.5.5-rc02"
44
authors = ["Simone Mosciatti <mweb.sim@gmail.com>"]
5+
edition = "2018"
56

67
[build-dependencies]
78
bindgen = "0.47.1"

redisql_lib/src/community_statement.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use sqlite::ffi;
2-
use sqlite::SQLiteConnection;
3-
use sqlite::StatementTrait;
4-
use sqlite::{Cursor, RawConnection, SQLite3Error, SQLiteOK};
1+
use crate::sqlite::ffi;
2+
use crate::sqlite::SQLiteConnection;
3+
use crate::sqlite::StatementTrait;
4+
use crate::sqlite::{Cursor, RawConnection, SQLite3Error, SQLiteOK};
55

66
use std::ffi::{CStr, CString};
77
use std::fmt;

redisql_lib/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#[macro_use]
44
extern crate log;
5-
extern crate serde;
65

76
pub mod community_statement;
87
pub mod redis;

redisql_lib/src/redis.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
extern crate fnv;
2-
3-
use self::fnv::FnvHashMap;
1+
use fnv::FnvHashMap;
42
use std;
53
use std::cell::RefCell;
64
use std::clone::Clone;
@@ -16,19 +14,21 @@ use std::str;
1614
use std::sync::mpsc::{Receiver, RecvError, Sender};
1715
use std::sync::{Arc, Mutex, MutexGuard, RwLock};
1816

19-
pub use redis_type as rm;
20-
use redis_type::{BlockedClient, Context, OpenKey, ReplyWithError};
17+
pub use crate::redis_type as rm;
18+
use crate::redis_type::{
19+
BlockedClient, Context, OpenKey, ReplyWithError,
20+
};
2121

22-
use redisql_error as err;
23-
use redisql_error::RediSQLError;
22+
use crate::redisql_error as err;
23+
use crate::redisql_error::RediSQLError;
2424

25-
use sqlite::StatementTrait;
25+
use crate::sqlite::StatementTrait;
2626

27-
use community_statement::MultiStatement;
27+
use crate::community_statement::MultiStatement;
2828

29-
use sqlite as sql;
29+
use crate::sqlite as sql;
3030

31-
use statistics::STATISTICS;
31+
use crate::statistics::STATISTICS;
3232

3333
#[derive(Clone)]
3434
pub struct ReplicationBook {
@@ -37,16 +37,16 @@ pub struct ReplicationBook {
3737
}
3838

3939
pub trait StatementCache<'a> {
40-
fn new(&Arc<Mutex<sql::RawConnection>>) -> Self;
41-
fn is_statement_present(&self, &str) -> bool;
40+
fn new(db: &Arc<Mutex<sql::RawConnection>>) -> Self;
41+
fn is_statement_present(&self, identifier: &str) -> bool;
4242
fn insert_new_statement(
4343
&mut self,
4444
identifier: &str,
4545
statement: &str,
4646
) -> Result<QueryResult, RediSQLError>;
4747
fn delete_statement(
4848
&mut self,
49-
&str,
49+
identifier: &str,
5050
) -> Result<QueryResult, RediSQLError>;
5151
fn update_statement(
5252
&mut self,
@@ -55,13 +55,13 @@ pub trait StatementCache<'a> {
5555
) -> Result<QueryResult, RediSQLError>;
5656
fn exec_statement(
5757
&self,
58-
&str,
59-
&[&str],
58+
identifier: &str,
59+
args: &[&str],
6060
) -> Result<QueryResult, RediSQLError>;
6161
fn query_statement(
6262
&self,
63-
&str,
64-
&[&str],
63+
identifier: &str,
64+
args: &[&str],
6565
) -> Result<QueryResult, RediSQLError>;
6666
}
6767

redisql_lib/src/redisql_error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::error;
22
use std::error::Error;
33
use std::fmt;
44

5-
use redis;
6-
use sqlite as sql;
5+
use crate::redis;
6+
use crate::sqlite as sql;
77

88
pub trait RediSQLErrorTrait: fmt::Display + error::Error {}
99

redisql_lib/src/sqlite.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ use std::os::raw::c_char;
77
use std::ptr;
88
use std::sync::{Arc, Mutex};
99

10-
use redis::QueryResult;
10+
use crate::redis::QueryResult;
1111

12-
use redisql_error as err;
12+
use crate::redisql_error as err;
1313

14-
use community_statement::Statement;
14+
use crate::community_statement::Statement;
1515

1616
#[allow(dead_code)]
1717
#[allow(non_snake_case)]

redisql_lib/src/virtual_tables.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
use redis_type::ffi as rffi;
2-
use redis_type::{CallReply, Context};
3-
use sqlite::ffi;
4-
use sqlite::{SQLite3Error, SQLiteConnection, SQLITE_TRANSIENT};
1+
use crate::redis_type::ffi as rffi;
2+
use crate::redis_type::{CallReply, Context};
3+
use crate::sqlite::ffi;
4+
use crate::sqlite::{
5+
SQLite3Error, SQLiteConnection, SQLITE_TRANSIENT,
6+
};
7+
58
use std::cell::RefCell;
69
use std::collections::VecDeque;
710
use std::ffi::{CStr, CString};

src/commands.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ use sync_engine::Replicate;
1717

1818
use redisql_lib::statistics::STATISTICS;
1919

20+
const REDISQL_VERSION: Option<&'static str> =
21+
option_env!("CARGO_PKG_VERSION");
22+
2023
extern "C" fn reply_exec(
2124
ctx: *mut r::rm::ffi::RedisModuleCtx,
2225
_argv: *mut *mut r::rm::ffi::RedisModuleString,
@@ -854,7 +857,7 @@ pub extern "C" fn CreateDB(
854857
vtab::register_modules(&rc)
855858
}) {
856859
Err(e) => e.reply(&context),
857-
Ok(mut vtab_context) => {
860+
Ok(vtab_context) => {
858861
let (tx, rx) = channel();
859862
let db = r::DBKey::new_from_arc(
860863
tx,
@@ -1096,3 +1099,16 @@ pub extern "C" fn GetStatistics(
10961099

10971100
r::rm::ffi::REDISMODULE_OK
10981101
}
1102+
1103+
#[allow(non_snake_case)]
1104+
pub extern "C" fn RediSQLVersion(
1105+
ctx: *mut r::rm::ffi::RedisModuleCtx,
1106+
_argv: *mut *mut r::rm::ffi::RedisModuleString,
1107+
_argc: ::std::os::raw::c_int,
1108+
) -> i32 {
1109+
let context = r::rm::Context::new(ctx);
1110+
let version = REDISQL_VERSION.unwrap_or("unknown");
1111+
r::rm::ReplyWithStringBuffer(&context, version.as_bytes());
1112+
1113+
r::rm::ffi::REDISMODULE_OK
1114+
}

0 commit comments

Comments
 (0)