4 个版本
使用旧的 Rust 2015
0.2.1 | 2016年6月4日 |
---|---|
0.2.0 | 2016年3月5日 |
0.1.1 | 2016年3月4日 |
0.1.0 | 2016年2月21日 |
#2967 in 数据库接口
10KB
230 行
disque-cli
Disque CLI.
构建
git clone https://github.com/iorust/disque-cli.git && cd disque-cli && cargo build --release
运行
target/release/disque-cli -h 127.0.0.1 -p 7711
更多帮助
target/release/disque-cli --help
作为 crate 使用
extern crate disque_cli;
// exports:
use disque_cli::{create_client, Client, COMMANDS, Value, encode_slice, Decoder};
Value, encode_slice, Decoder
从 https://github.com/iorust/resp 重新导出
fn create_client(host: &str, port: u16, password: &str) -> io::Result<Client>
let mut client = create_client("127.0.0.1", 7711, "").expect("Failed to connect");
client.cmd(&["hello"]).unwrap();
Client
struct Client {
// some fields omitted
}
impl Client
fn new<A:ToSocketAddrs>(addrs:A) -> Self
let mut client = Client::new((hostname, port));
fn cmd(&mut self, slice: &[&str]) -> Result<Value>
client.cmd(&["addjob", "test", "hello, world!", "100"]).unwrap(); // Value::String("hello!")
fn read_more(&mut self) -> Result<Value>
某些命令将有多一个回复。此方法用于读取它们。
client.read_more().unwrap();
COMMANDS
https://github.com/iorust/disque-cli/blob/master/src/command.rs
依赖项
~1MB
~11K SLoC