use crate::msgpack::encoder::pack_cdt_op;
use crate::operations::cdt::{CdtArgument, CdtOperation};
use crate::operations::cdt_context::{CdtContext, DEFAULT_CTX};
use crate::operations::{Operation, OperationBin, OperationData, OperationType};
use crate::Value;
#[derive(Debug, Clone, Copy)]
#[doc(hidden)]
pub enum CdtListOpType {
SetType = 0,
Append = 1,
AppendItems = 2,
Insert = 3,
InsertItems = 4,
Pop = 5,
PopRange = 6,
Remove = 7,
RemoveRange = 8,
Set = 9,
Trim = 10,
Clear = 11,
Increment = 12,
Sort = 13,
Size = 16,
Get = 17,
GetRange = 18,
GetByIndex = 19,
GetByRank = 21,
GetByValue = 22,
GetByValueList = 23,
GetByIndexRange = 24,
GetByValueInterval = 25,
GetByRankRange = 26,
GetByValueRelRankRange = 27,
RemoveByIndex = 32,
RemoveByRank = 34,
RemoveByValue = 35,
RemoveByValueList = 36,
RemoveByIndexRange = 37,
RemoveByValueInterval = 38,
RemoveByRankRange = 39,
RemoveByValueRelRankRange = 40,
}
#[derive(Debug, Clone, Copy)]
pub enum ListOrderType {
Unordered = 0,
Ordered = 1,
}
#[derive(Debug, Clone, Copy)]
pub enum ListReturnType {
None = 0,
Index = 1,
ReverseIndex = 2,
Rank = 3,
ReverseRank = 4,
Count = 5,
Values = 7,
Inverted = 0x10000,
}
#[derive(Debug, Clone, Copy)]
pub enum ListSortFlags {
Default = 0,
Descending = 1,
DropDuplicates = 2,
}
#[derive(Debug, Clone, Copy)]
pub enum ListWriteFlags {
Default = 0,
AddUnique = 1,
InsertBounded = 2,
NoFail = 4,
Partial = 8,
}
#[derive(Debug, Clone, Copy)]
pub struct ListPolicy {
pub attributes: ListOrderType,
pub flags: ListWriteFlags,
}
impl ListPolicy {
pub const fn new(order: ListOrderType, write_flags: ListWriteFlags) -> Self {
ListPolicy {
attributes: order,
flags: write_flags,
}
}
}
impl Default for ListPolicy {
fn default() -> Self {
ListPolicy::new(ListOrderType::Unordered, ListWriteFlags::Default)
}
}
#[doc(hidden)]
pub const fn list_order_flag(order: ListOrderType, pad: bool) -> u8 {
if let ListOrderType::Ordered = order {
return 0xc0;
}
if pad {
return 0x80;
}
0x40
}
pub fn create(bin: &str, list_order: ListOrderType, pad: bool) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::SetType as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(list_order_flag(list_order, pad)),
CdtArgument::Byte(list_order as u8),
],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn set_order<'a>(
bin: &'a str,
list_order: ListOrderType,
ctx: &'a [CdtContext],
) -> Operation<'a> {
let cdt_op = CdtOperation {
op: CdtListOpType::SetType as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Byte(list_order as u8)],
};
Operation {
op: OperationType::CdtWrite,
ctx,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn append<'a>(policy: &ListPolicy, bin: &'a str, value: &'a Value) -> Operation<'a> {
let cdt_op = CdtOperation {
op: CdtListOpType::Append as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Value(value),
CdtArgument::Byte(policy.attributes as u8),
CdtArgument::Byte(policy.flags as u8),
],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn append_items<'a>(policy: &ListPolicy, bin: &'a str, values: &'a [Value]) -> Operation<'a> {
assert!(!values.is_empty());
let cdt_op = CdtOperation {
op: CdtListOpType::AppendItems as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::List(values),
CdtArgument::Byte(policy.attributes as u8),
CdtArgument::Byte(policy.flags as u8),
],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn insert<'a>(
policy: &ListPolicy,
bin: &'a str,
index: i64,
value: &'a Value,
) -> Operation<'a> {
let cdt_op = CdtOperation {
op: CdtListOpType::Insert as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Int(index),
CdtArgument::Value(value),
CdtArgument::Byte(policy.flags as u8),
],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn insert_items<'a>(
policy: &ListPolicy,
bin: &'a str,
index: i64,
values: &'a [Value],
) -> Operation<'a> {
assert!(!values.is_empty());
let cdt_op = CdtOperation {
op: CdtListOpType::InsertItems as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Int(index),
CdtArgument::List(values),
CdtArgument::Byte(policy.flags as u8),
],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn pop(bin: &str, index: i64) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::Pop as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Int(index)],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn pop_range(bin: &str, index: i64, count: i64) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::PopRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Int(index), CdtArgument::Int(count)],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn pop_range_from(bin: &str, index: i64) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::PopRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Int(index)],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn remove(bin: &str, index: i64) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::Remove as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Int(index)],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn remove_range(bin: &str, index: i64, count: i64) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::RemoveRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Int(index), CdtArgument::Int(count)],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn remove_range_from(bin: &str, index: i64) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::RemoveRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Int(index)],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn remove_by_value<'a>(
bin: &'a str,
value: &'a Value,
return_type: ListReturnType,
) -> Operation<'a> {
let cdt_op = CdtOperation {
op: CdtListOpType::RemoveByValue as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::Value(value),
],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn remove_by_value_list<'a>(
bin: &'a str,
values: &'a [Value],
return_type: ListReturnType,
) -> Operation<'a> {
let cdt_op = CdtOperation {
op: CdtListOpType::RemoveByValueList as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::List(values),
],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn remove_by_value_range<'a>(
bin: &'a str,
return_type: ListReturnType,
begin: &'a Value,
end: &'a Value,
) -> Operation<'a> {
let cdt_op = CdtOperation {
op: CdtListOpType::RemoveByValueInterval as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::Value(begin),
CdtArgument::Value(end),
],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn remove_by_value_relative_rank_range<'a>(
bin: &'a str,
return_type: ListReturnType,
value: &'a Value,
rank: i64,
) -> Operation<'a> {
let cdt_op = CdtOperation {
op: CdtListOpType::RemoveByValueRelRankRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::Value(value),
CdtArgument::Int(rank),
],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn remove_by_value_relative_rank_range_count<'a>(
bin: &'a str,
return_type: ListReturnType,
value: &'a Value,
rank: i64,
count: i64,
) -> Operation<'a> {
let cdt_op = CdtOperation {
op: CdtListOpType::RemoveByValueRelRankRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::Value(value),
CdtArgument::Int(rank),
CdtArgument::Int(count),
],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn remove_by_index(bin: &str, index: i64, return_type: ListReturnType) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::RemoveByIndex as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::Int(index),
],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn remove_by_index_range(bin: &str, index: i64, return_type: ListReturnType) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::RemoveByIndexRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::Int(index),
],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn remove_by_index_range_count(
bin: &str,
index: i64,
count: i64,
return_type: ListReturnType,
) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::RemoveByIndexRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::Int(index),
CdtArgument::Int(count),
],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn remove_by_rank(bin: &str, rank: i64, return_type: ListReturnType) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::RemoveByRank as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Byte(return_type as u8), CdtArgument::Int(rank)],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn remove_by_rank_range(bin: &str, rank: i64, return_type: ListReturnType) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::RemoveByRankRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Byte(return_type as u8), CdtArgument::Int(rank)],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn remove_by_rank_range_count(
bin: &str,
rank: i64,
count: i64,
return_type: ListReturnType,
) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::RemoveByRankRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::Int(rank),
CdtArgument::Int(count),
],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn set<'a>(bin: &'a str, index: i64, value: &'a Value) -> Operation<'a> {
assert!(!value.is_nil());
let cdt_op = CdtOperation {
op: CdtListOpType::Set as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Int(index), CdtArgument::Value(value)],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn trim(bin: &str, index: i64, count: i64) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::Trim as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Int(index), CdtArgument::Int(count)],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn clear(bin: &str) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::Clear as u8,
encoder: Box::new(pack_cdt_op),
args: vec![],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn increment<'a>(policy: &ListPolicy, bin: &'a str, index: i64, value: i64) -> Operation<'a> {
let cdt_op = CdtOperation {
op: CdtListOpType::Increment as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Int(index),
CdtArgument::Int(value),
CdtArgument::Byte(policy.flags as u8),
],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn size(bin: &str) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::Size as u8,
encoder: Box::new(pack_cdt_op),
args: vec![],
};
Operation {
op: OperationType::CdtRead,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn get(bin: &str, index: i64) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::Get as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Int(index)],
};
Operation {
op: OperationType::CdtRead,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn get_range(bin: &str, index: i64, count: i64) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::GetRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Int(index), CdtArgument::Int(count)],
};
Operation {
op: OperationType::CdtRead,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn get_range_from(bin: &str, index: i64) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::GetRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Int(index)],
};
Operation {
op: OperationType::CdtRead,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn get_by_value<'a>(
bin: &'a str,
value: &'a Value,
return_type: ListReturnType,
) -> Operation<'a> {
let cdt_op = CdtOperation {
op: CdtListOpType::GetByValue as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::Value(value),
],
};
Operation {
op: OperationType::CdtRead,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn get_by_value_list<'a>(
bin: &'a str,
values: &'a [Value],
return_type: ListReturnType,
) -> Operation<'a> {
let cdt_op = CdtOperation {
op: CdtListOpType::GetByValueList as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::List(values),
],
};
Operation {
op: OperationType::CdtRead,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn get_by_value_range<'a>(
bin: &'a str,
begin: &'a Value,
end: &'a Value,
return_type: ListReturnType,
) -> Operation<'a> {
let cdt_op = CdtOperation {
op: CdtListOpType::GetByValueInterval as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::Value(begin),
CdtArgument::Value(end),
],
};
Operation {
op: OperationType::CdtRead,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn get_by_index(bin: &str, index: i64, return_type: ListReturnType) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::GetByIndex as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::Int(index),
],
};
Operation {
op: OperationType::CdtRead,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn get_by_index_range(bin: &str, index: i64, return_type: ListReturnType) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::GetByIndexRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::Int(index),
],
};
Operation {
op: OperationType::CdtRead,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn get_by_index_range_count(
bin: &str,
index: i64,
count: i64,
return_type: ListReturnType,
) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::GetByIndexRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::Int(index),
CdtArgument::Int(count),
],
};
Operation {
op: OperationType::CdtRead,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn get_by_rank(bin: &str, rank: i64, return_type: ListReturnType) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::GetByRank as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Byte(return_type as u8), CdtArgument::Int(rank)],
};
Operation {
op: OperationType::CdtRead,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn get_by_rank_range(bin: &str, rank: i64, return_type: ListReturnType) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::GetByRankRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Byte(return_type as u8), CdtArgument::Int(rank)],
};
Operation {
op: OperationType::CdtRead,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn get_by_rank_range_count(
bin: &str,
rank: i64,
count: i64,
return_type: ListReturnType,
) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::GetByRankRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::Int(rank),
CdtArgument::Int(count),
],
};
Operation {
op: OperationType::CdtRead,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn get_by_value_relative_rank_range<'a>(
bin: &'a str,
value: &'a Value,
rank: i64,
return_type: ListReturnType,
) -> Operation<'a> {
let cdt_op = CdtOperation {
op: CdtListOpType::GetByValueRelRankRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::Value(value),
CdtArgument::Int(rank),
],
};
Operation {
op: OperationType::CdtRead,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn get_by_value_relative_rank_range_count<'a>(
bin: &'a str,
value: &'a Value,
rank: i64,
count: i64,
return_type: ListReturnType,
) -> Operation<'a> {
let cdt_op = CdtOperation {
op: CdtListOpType::GetByValueRelRankRange as u8,
encoder: Box::new(pack_cdt_op),
args: vec![
CdtArgument::Byte(return_type as u8),
CdtArgument::Value(value),
CdtArgument::Int(rank),
CdtArgument::Int(count),
],
};
Operation {
op: OperationType::CdtRead,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}
pub fn sort(bin: &str, sort_flags: ListSortFlags) -> Operation {
let cdt_op = CdtOperation {
op: CdtListOpType::Sort as u8,
encoder: Box::new(pack_cdt_op),
args: vec![CdtArgument::Byte(sort_flags as u8)],
};
Operation {
op: OperationType::CdtWrite,
ctx: DEFAULT_CTX,
bin: OperationBin::Name(bin),
data: OperationData::CdtListOp(cdt_op),
}
}