fix: /etherdream some cleanup and better error management

This commit is contained in:
alban 2023-07-19 21:39:25 +02:00
parent ae75092d34
commit 8e10e0d82e
3 changed files with 78 additions and 91 deletions

View file

@ -1,24 +1,34 @@
///
/// $ cargo run --example populate_redis
///
use std::io::_print;
/**
# Populate Redis Example
**This script simulates the redis content provided by the LJ Python / web tool**
$ cargo run --example populate_redis
**/
use redis::{
//RedisResult,
Client,
Commands,
Connection,
//RedisResult,
Client,
Commands,
Connection,
};
fn do_something() -> redis::RedisResult<()> {
let client = Client::open("redis://127.0.0.1/")?;
let mut con: Connection = client.get_connection()?;
let client = Client::open("redis://127.0.0.1/")?;
let mut con: Connection = client.get_connection()?;
let _ = con.set("/clientkey", "/pl/0/")?;
let _ = con.set("/EDH/0", "[[1.0, 0.0, 0.0],\n [ 0.0, 1.0, 0.0],\n [ 0.0, 0.0, 1.0]]")?;
let _ = con.set("/kpps/0", "5000")?;
let _ = con.set("/intensity/0", "255")?;
Ok(())
let _ = con.set("/pl/0/0", "[(-300, 300, 0), (-300, -300, 65280), (300, -300, 65280), (300, 300, 65280), (-300, 300, 65280)]")?;
Ok(())
}
fn main() {
_ = do_something();
match do_something() {
Err(err) => println!("Something wrong occured: {:?}", err),
Ok(..) => println!("Successfully inserted content in Redis")
}
}