keyz_rust_client

Crates.iokeyz_rust_client
lib.rskeyz_rust_client
version1.0.5
sourcesrc
created_at2023-01-27 16:27:55.076429
updated_at2023-01-27 17:29:48.431984
descriptionkeyz client for Rust
homepage
repositoryhttps://github.com/viktor111/keyz_rust_client.git
max_upload_size
id769772
size9,480
Viktor Draganov (viktor111)

documentation

README

keyz_rust_client

Rust client for keyz

Getting started

  • Import
    use keyz_rust_client::{ Keyz };
    
  • Initialize the connection to running keyz server
    let keyz = Keyz::new("127.0.0.1".to_owned(), 7667).await;
    
  • Set value where key is test and value is 1
    let result = keyz.set("test", "1", None).await.unwrap();
    
  • Set value where key is test and value is 1 with expiry time in seconds
    let req = keyz.set("test", "1", Some(20)).await.unwrap();
    
  • Get value with key test
    let result = keyz.get("test").await.unwrap();
    
  • Delete value with key test
    let result = keyz.delete("test").await.unwrap();
    
  • Get the time left for the key test to expire
    let result = keyz.expires_in("test").await.unwrap();
    
  • Dispose connection
    keyz.dispose().await.unwrap();
    

!!! Important make sure to dispose of connection when not needed anymore

Using direct send message

let keyz = Keyz::new("127.0.0.1".to_owned(), 7667).await;
keyz.send_message("SET test 1").await.unwrap();
keyz.dispose().await.unwrap();

It is not advised to directly use this because some command currently are not fully supported with this method. You can learn more about all the commands in the keyz repo here

Commit count: 22

cargo fmt