Skip to content

Commit

Permalink
Added from constructor. Deprecated new constructor!
Browse files Browse the repository at this point in the history
  • Loading branch information
younisshah committed Jul 25, 2017
1 parent 8e11db8 commit f42cd15
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nazar"
version = "1.0.0"
version = "1.0.1"
authors = ["Younis Shah <younisashah@gmail.com>"]
description = "A Tile38 client in rust!"
homepage = "https://github.com/younisshah/nazar"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ In your `Cargo.toml` file add under `[dependencies]` section

```ini
[dependencies]
nazar = "1.0.0"
nazar = "1.0.1"
```

### Usage
Expand All @@ -25,7 +25,7 @@ nazar = "1.0.0"

```rust
use self::nazar::t38::Types::{String, Float};
let n = nazar::t38::Client::new("redis://127.0.0.1:9851");
let n = nazar::t38::Client::from("redis://127.0.0.1:9851"); // new is now deprecated!

match n.execute("SET", vec![String("my"), String("home"), Float(23.12), Float(45.343)]) {
Ok(s) => println!("{}", s),
Expand All @@ -38,7 +38,7 @@ match n.execute("SET", vec![String("my"), String("home"), Float(23.12), Float(45

```rust
use self::nazar::t38::Types::{String};
let n = nazar::t38::Client::new("redis://127.0.0.1:9851");
let n = nazar::t38::Client::from("redis://127.0.0.1:9851"); // new is now deprecated!

match n.execute("GET", vec![String("my"), String("home")]) {
Ok(s) => println!("{}", s),
Expand Down
9 changes: 7 additions & 2 deletions src/t38.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,27 @@ extern crate ws;
type NazarResult<T> = redis::RedisResult<T>;

/// Represents T38 types
#[allow(dead_code)]
pub enum Types {
String(&'static str),
Int(isize),
Float(f32)
}

#[derive(Debug, Clone, Copy)]
#[derive(Clone, Copy)]
pub struct Client {
url: &'static str
}

impl Client {
#[deprecated(since="1.0.1", note= "Please use `from` instead.")]
pub fn new(url: &'static str) -> Self {
Client { url }
}
/// Constructor with one argument - Rust convention!
pub fn from(url: &'static str) -> Self {
Client { url }
}
/// low level API
pub fn execute(self, command: &str, args: Vec<Types>) -> NazarResult<String> {
let mut command = redis::cmd(command);
for e in args {
Expand Down

0 comments on commit f42cd15

Please sign in to comment.