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§
Sourcefn from_graph_value(value: GraphValue) -> RedisResult<Self>
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
impl FromGraphValue for bool
fn from_graph_value(value: GraphValue) -> RedisResult<Self>
Source§impl FromGraphValue for f64
Macro for implementing the FromGraphValue Trait for a float type
impl FromGraphValue for f64
Macro for implementing the FromGraphValue Trait for a float type