[][src]Struct rusty_tarantool::tarantool::Client

pub struct Client { /* fields omitted */ }

API to tarantool.

Create client by call build() on ClientConfig.

Examples

let client = ClientConfig::new(addr, "rust", "rust").set_timeout_time_ms(1000).set_reconnect_time_ms(10000).build();

Implementations

impl Client[src]

pub fn new(config: ClientConfig) -> Client[src]

manually create client by consume Client Config

pub fn get_status(&self) -> ClientStatus[src]

return client status

pub fn subscribe_to_notify_stream(
    &self
) -> impl Stream<Item = ClientStatus, Error = ()>
[src]

return notify stream with connection statuses

pub fn send_command(
    &self,
    req: CommandPacket
) -> impl Future<Item = TarantoolResponse, Error = Error>
[src]

send any command you manually create, this method is low level and not intended to be used

pub fn call_fn<T>(
    &self,
    function: &str,
    params: &T
) -> impl Future<Item = TarantoolResponse, Error = Error> where
    T: Serialize
[src]

call tarantool stored procedure

params mast be serializable to MsgPack tuple by Serde - rust tuple or vector or struct (by default structs serialized as tuple)

order of fields in serializes tuple is order od parameters of procedure

Examples

lua function on tarantool

function test(a,b)
  return a,b,11
 end

rust code

let resp = client.call_fn("test", &(("aa", "aa"), 1))
       .and_then(move |response| {
           println!("response2: {:?}", response);
           let s: (Vec<String>, Vec<u64>) = response.decode_pair()?;
           println!("resp value={:?}", s);
           assert_eq!((vec!["aa".to_string(), "aa".to_string()], vec![1]), s);
           Ok(())
       })

pub fn call_fn1<T1>(
    &self,
    function: &str,
    param1: &T1
) -> impl Future<Item = TarantoolResponse, Error = Error> where
    T1: Serialize
[src]

call tarantool stored procedure with one parameter

pub fn call_fn2<T1, T2>(
    &self,
    function: &str,
    param1: &T1,
    param2: &T2
) -> impl Future<Item = TarantoolResponse, Error = Error> where
    T1: Serialize,
    T2: Serialize
[src]

call tarantool stored procedure with two parameters

Examples

 let response_future = client.call_fn2("test", &("param11", "param12") , &2)
        .and_then(|response| {
            let res : ((String,String), (u64,), (Option<u64>,)) = response.decode_trio()?;
            Ok(res)
        }) ;

pub fn call_fn3<T1, T2, T3>(
    &self,
    function: &str,
    param1: &T1,
    param2: &T2,
    param3: &T3
) -> impl Future<Item = TarantoolResponse, Error = Error> where
    T1: Serialize,
    T2: Serialize,
    T3: Serialize
[src]

call tarantool stored procedure with three parameters

pub fn call_fn4<T1, T2, T3, T4>(
    &self,
    function: &str,
    param1: &T1,
    param2: &T2,
    param3: &T3,
    param4: &T4
) -> impl Future<Item = TarantoolResponse, Error = Error> where
    T1: Serialize,
    T2: Serialize,
    T3: Serialize,
    T4: Serialize
[src]

call tarantool stored procedure with four parameters

pub fn call_fn5<T1, T2, T3, T4, T5>(
    &self,
    function: &str,
    param1: &T1,
    param2: &T2,
    param3: &T3,
    param4: &T4,
    param5: &T5
) -> impl Future<Item = TarantoolResponse, Error = Error> where
    T1: Serialize,
    T2: Serialize,
    T3: Serialize,
    T4: Serialize,
    T5: Serialize
[src]

call tarantool stored procedure with five parameters

pub fn select<T>(
    &self,
    space: i32,
    index: i32,
    key: &T,
    offset: i32,
    limit: i32,
    iterator: i32
) -> impl Future<Item = TarantoolResponse, Error = Error> where
    T: Serialize
[src]

call "select" from tarantool

  • space - i32 space id
  • index - i32 index id
  • key - key part used for select, may be sequence (vec or tuple)
  • offset - i32 select offset
  • limit - i32 limit of rows
  • iterator - type of iterator

pub fn insert<T>(
    &self,
    space: i32,
    tuple: &T
) -> impl Future<Item = TarantoolResponse, Error = Error> where
    T: Serialize
[src]

insert tuple to space

  • space - space id
  • tuple - sequence of fields(can be vec or rust tuple)

pub fn replace<T>(
    &self,
    space: i32,
    tuple: &T
) -> impl Future<Item = TarantoolResponse, Error = Error> where
    T: Serialize
[src]

replace tuple in space by primary key

  • space - space id
  • tuple - sequence of fields(can be vec or rust tuple)

Examples

let tuple_replace= (3,"test_insert","replace");
client.replace(SPACE_ID, &tuple_replace)

pub fn replace_raw(
    &self,
    space: i32,
    tuple_raw: Vec<u8>
) -> impl Future<Item = TarantoolResponse, Error = Error>
[src]

replace tuple in space by primary key - raw method if you have already serialized msgpack

  • space - space id
  • tuple - sequence of fields stored as msgpack

Examples

let tuple_replace= (3,"test_insert","replace");
let raw_buf = serialize_to_vec_u8(&tuple_replace).unwrap();
client.replace_raw(SPACE_ID, raw_buf)

pub fn update<T, T2>(
    &self,
    space: i32,
    key: &T2,
    args: &T
) -> impl Future<Item = TarantoolResponse, Error = Error> where
    T: Serialize,
    T2: Serialize
[src]

update row in tarantool

  • space - space id
  • key - sequence of fields(rust tuple or vec)
  • args - sequence of update operations, for example (('=',2,"test_update"),)

Examples

let tuple= (3,"test_insert");
let update_op= (('=',2,"test_update"),);
client.update(SPACE_ID, &tuple, &update_op)

pub fn upsert<T, T2, T3>(
    &self,
    space: i32,
    key: &T2,
    def: &T3,
    args: &T
) -> impl Future<Item = TarantoolResponse, Error = Error> where
    T: Serialize,
    T2: Serialize,
    T3: Serialize
[src]

upsert row in tuple

Examples

let key= (4,"test_upsert");
let update_op= (('=',2,"test_update_upsert"),);
client.upsert(SPACE_ID,&key, &key,&update_op)

pub fn delete<T>(
    &self,
    space: i32,
    key: &T
) -> impl Future<Item = TarantoolResponse, Error = Error> where
    T: Serialize
[src]

delete row in space

Examples

let tuple= (3,"test_insert");
client.delete(SPACE_ID,&tuple)

pub fn eval<T>(
    &self,
    expression: String,
    args: &T
) -> impl Future<Item = TarantoolResponse, Error = Error> where
    T: Serialize
[src]

eval expression in tarantool

Examples

client.eval("return ...\n".to_string(),&(1,2))

pub fn ping(&self) -> impl Future<Item = TarantoolResponse, Error = Error>[src]

ping tarantool server, return empty response in success

Examples

client.ping()

Trait Implementations

impl Clone for Client[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.