Trait fred::interfaces::RedisJsonInterface

source ·
pub trait RedisJsonInterface: ClientLike + Sized {
Show 22 methods // Provided methods fn json_arrappend<R, K, P, V>( &self, key: K, path: P, values: Vec<V>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str>, V: Into<Value> { ... } fn json_arrindex<R, K, P, V>( &self, key: K, path: P, value: V, start: Option<i64>, stop: Option<i64>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str>, V: Into<Value> { ... } fn json_arrinsert<R, K, P, V>( &self, key: K, path: P, index: i64, values: Vec<V>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str>, V: Into<Value> { ... } fn json_arrlen<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str> { ... } fn json_arrpop<R, K, P>( &self, key: K, path: Option<P>, index: Option<i64>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str> { ... } fn json_arrtrim<R, K, P>( &self, key: K, path: P, start: i64, stop: i64, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str> { ... } fn json_clear<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str> { ... } fn json_debug_memory<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str> { ... } fn json_del<R, K, P>( &self, key: K, path: P, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str> { ... } fn json_get<R, K, I, N, S, P>( &self, key: K, indent: Option<I>, newline: Option<N>, space: Option<S>, paths: P, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, I: Into<Str>, N: Into<Str>, S: Into<Str>, P: Into<MultipleStrings> { ... } fn json_merge<R, K, P, V>( &self, key: K, path: P, value: V, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str>, V: Into<Value> { ... } fn json_mget<R, K, P>( &self, keys: K, path: P, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<MultipleKeys>, P: Into<Str> { ... } fn json_mset<R, K, P, V>( &self, values: Vec<(K, P, V)>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str>, V: Into<Value> { ... } fn json_numincrby<R, K, P, V>( &self, key: K, path: P, value: V, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str>, V: Into<Value> { ... } fn json_objkeys<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str> { ... } fn json_objlen<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str> { ... } fn json_resp<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str> { ... } fn json_set<R, K, P, V>( &self, key: K, path: P, value: V, options: Option<SetOptions>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str>, V: Into<Value> { ... } fn json_strappend<R, K, P, V>( &self, key: K, path: Option<P>, value: V, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str>, V: Into<Value> { ... } fn json_strlen<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str> { ... } fn json_toggle<R, K, P>( &self, key: K, path: P, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str> { ... } fn json_type<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>> where R: FromRedis, K: Into<RedisKey>, P: Into<Str> { ... }
}
Available on crate feature i-redis-json only.
Expand description

The client commands in the RedisJSON interface.

§String Values

This interface uses serde_json::Value as the baseline type and will convert non-string values to RESP bulk strings via to_string.

Some of the RedisJSON commands include the following notice in the documentation:

To specify a string as an array value to append, wrap the quoted string with an additional set of single quotes. Example: ‘“silver”’.

The serde_json::to_string functions are often the easiest way to do this. The json_quote macro can also help.

For example:

use fred::{json_quote, prelude::*};
use serde_json::json;
async fn example(client: &RedisClient) -> Result<(), RedisError> {
  let _: () = client.json_set("foo", "$", json!(["a", "b"]), None).await?;

  // need to double quote string values in this context
  let size: i64 = client
    .json_arrappend("foo", Some("$"), vec![
      json!("c").to_string(),
      // or
      serde_json::to_string(&json!("d"))?,
      // or
      json_quote!("e"),
    ])
    .await?;
  assert_eq!(size, 5);
  Ok(())
}

Provided Methods§

source

fn json_arrappend<R, K, P, V>( &self, key: K, path: P, values: Vec<V>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>, V: Into<Value>,

Append the json values into the array at path after the last element in it.

https://redis.io/commands/json.arrappend

source

fn json_arrindex<R, K, P, V>( &self, key: K, path: P, value: V, start: Option<i64>, stop: Option<i64>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>, V: Into<Value>,

Search for the first occurrence of a JSON value in an array.

https://redis.io/commands/json.arrindex/

source

fn json_arrinsert<R, K, P, V>( &self, key: K, path: P, index: i64, values: Vec<V>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>, V: Into<Value>,

Insert the json values into the array at path before the index (shifts to the right).

https://redis.io/commands/json.arrinsert/

source

fn json_arrlen<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>,

Report the length of the JSON array at path in key.

https://redis.io/commands/json.arrlen/

source

fn json_arrpop<R, K, P>( &self, key: K, path: Option<P>, index: Option<i64>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>,

Remove and return an element from the index in the array

https://redis.io/commands/json.arrpop/

source

fn json_arrtrim<R, K, P>( &self, key: K, path: P, start: i64, stop: i64, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>,

Trim an array so that it contains only the specified inclusive range of elements

https://redis.io/commands/json.arrtrim/

source

fn json_clear<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>,

Clear container values (arrays/objects) and set numeric values to 0

https://redis.io/commands/json.clear/

source

fn json_debug_memory<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>,

Report a value’s memory usage in bytes

https://redis.io/commands/json.debug-memory/

source

fn json_del<R, K, P>( &self, key: K, path: P, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>,

source

fn json_get<R, K, I, N, S, P>( &self, key: K, indent: Option<I>, newline: Option<N>, space: Option<S>, paths: P, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, I: Into<Str>, N: Into<Str>, S: Into<Str>, P: Into<MultipleStrings>,

Return the value at path in JSON serialized form.

https://redis.io/commands/json.get/

source

fn json_merge<R, K, P, V>( &self, key: K, path: P, value: V, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>, V: Into<Value>,

Merge a given JSON value into matching paths.

https://redis.io/commands/json.merge/

source

fn json_mget<R, K, P>( &self, keys: K, path: P, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<MultipleKeys>, P: Into<Str>,

Return the values at path from multiple key arguments.

https://redis.io/commands/json.mget/

source

fn json_mset<R, K, P, V>( &self, values: Vec<(K, P, V)>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>, V: Into<Value>,

Set or update one or more JSON values according to the specified key-path-value triplets.

https://redis.io/commands/json.mset/

source

fn json_numincrby<R, K, P, V>( &self, key: K, path: P, value: V, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>, V: Into<Value>,

Increment the number value stored at path by number

https://redis.io/commands/json.numincrby/

source

fn json_objkeys<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>,

Return the keys in the object that’s referenced by path.

https://redis.io/commands/json.objkeys/

source

fn json_objlen<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>,

Report the number of keys in the JSON object at path in key.

https://redis.io/commands/json.objlen/

source

fn json_resp<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>,

Return the JSON in key in Redis serialization protocol specification form.

https://redis.io/commands/json.resp/

source

fn json_set<R, K, P, V>( &self, key: K, path: P, value: V, options: Option<SetOptions>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>, V: Into<Value>,

Set the JSON value at path in key.

https://redis.io/commands/json.set/

source

fn json_strappend<R, K, P, V>( &self, key: K, path: Option<P>, value: V, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>, V: Into<Value>,

Append the json-string values to the string at path.

https://redis.io/commands/json.strappend/

source

fn json_strlen<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>,

Report the length of the JSON String at path in key.

https://redis.io/commands/json.strlen/

source

fn json_toggle<R, K, P>( &self, key: K, path: P, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>,

Toggle a Boolean value stored at path.

https://redis.io/commands/json.toggle/

source

fn json_type<R, K, P>( &self, key: K, path: Option<P>, ) -> impl Future<Output = RedisResult<R>>
where R: FromRedis, K: Into<RedisKey>, P: Into<Str>,

Report the type of JSON value at path.

https://redis.io/commands/json.type/

Object Safety§

This trait is not object safe.

Implementors§