Trait FromGraphValue

Source
pub trait FromGraphValue: Sized {
    // Required method
    fn from_graph_value(value: GraphValue) -> RedisResult<Self>;
}
Expand description

Trait for converting the response to an arbitray type which implents the trait This is similar to the FromRedisValue trait from redis

§Example

struct MyType {
    a: i32
    b: Vec<String>
}
 
impl FromGraphValue for MyType {
    fn from_graph_value(value: GraphValue) -> RedisResult<Self> {
        let (a, b): (i32, Vec<String>) = from_graph_value(value)?;
        // You dont even need the type annotations above as they are inferred in this case
        Ok(MyType {
            a,
            b
        })
    }
}
// Now you can write code like this
let con = // Connection to redis
let data: Vec<MyType> = con.graph_query("graphname", query!("RETURN 1, ['a', 'b']"))?.data;

Required Methods§

Source

fn from_graph_value(value: GraphValue) -> RedisResult<Self>

Converts the GraphValue to the implementing Type

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl FromGraphValue for bool

Source§

impl FromGraphValue for f64

Macro for implementing the FromGraphValue Trait for a float type

Source§

impl FromGraphValue for i8

Source§

impl FromGraphValue for i16

Source§

impl FromGraphValue for i32

Source§

impl FromGraphValue for i64

Source§

impl FromGraphValue for u8

Source§

impl FromGraphValue for u16

Source§

impl FromGraphValue for u32

Source§

impl FromGraphValue for u64

Source§

impl FromGraphValue for ()

Source§

impl FromGraphValue for String

Source§

impl<T: FromGraphValue> FromGraphValue for Option<T>

Source§

impl<T: FromGraphValue> FromGraphValue for Vec<T>

Implementors§