Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 104 additions & 89 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ name = "rejson"
[dependencies]
log = "0.4"
bson = "0.14"
ijson = "0.1.3"
serde_json = "1.0"
serde = "1.0"
libc = "0.2"
jsonpath_lib = { git = "https://github.com/RedisJSON/jsonpath.git", branch = "generic_json_path" }
redis-module = { version="0.24", features = ["experimental-api"]}
redis-module = { version="0.25", features = ["experimental-api"]}
itertools = "0.10.1"
[features]
# Workaround to allow cfg(feature = "test") in redismodue-rs dependencies:
Expand Down
28 changes: 1 addition & 27 deletions src/c_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ use std::{
use crate::commands::KeyValue;
use jsonpath_lib::select::select_value::{SelectValue, SelectValueType};
use jsonpath_lib::select::Selector;
use redis_module::{raw as rawmod, RedisError};
use redis_module::raw as rawmod;
use redis_module::{Context, RedisString, Status};
use serde_json::Value;

use crate::manager::{Manager, ReadHolder};
use crate::redisjson::RedisJSON;

// extern crate readies_wd40;
// use crate::readies_wd40::{BB, _BB, getenv};
Expand Down Expand Up @@ -172,30 +170,6 @@ pub fn json_api_get_boolean<M: Manager>(_: M, json: *const c_void, val: *mut c_i

//---------------------------------------------------------------------------------------------

pub fn value_from_index(value: &Value, index: size_t) -> Result<&Value, RedisError> {
match value {
Value::Array(ref vec) => {
if index < vec.len() {
Ok(vec.get(index).unwrap())
} else {
Err(RedisError::Str("JSON index is out of range"))
}
}
Value::Object(ref map) => {
if index < map.len() {
Ok(map.iter().nth(index).unwrap().1)
} else {
Err(RedisError::Str("JSON index is out of range"))
}
}
_ => Err(RedisError::Str("Not a JSON Array or Object")),
}
}

pub fn get_type_and_size(value: &Value) -> (JSONType, size_t) {
RedisJSON::get_type_and_size(value)
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn set_string(from_str: &str, str: *mut *const c_char, len: *mut size_t) -> c_int {
if !str.is_null() {
Expand Down
Loading