From 378ff608430bee0ad3a0bc073767eb6015e437de Mon Sep 17 00:00:00 2001 From: juliannguyen4 <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 5 Feb 2024 18:35:18 -0800 Subject: [PATCH 1/8] Derive Clone trait for Operation struct --- src/operations/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/operations/mod.rs b/src/operations/mod.rs index 57e38a50..78869b53 100644 --- a/src/operations/mod.rs +++ b/src/operations/mod.rs @@ -75,6 +75,7 @@ pub enum OperationBin<'a> { } /// Database operation definition. This data type is used in the client's `operate()` method. +#[derive(Clone)] pub struct Operation<'a> { // OpType determines type of operation. #[doc(hidden)] From 171b478f3b1a1582c3f4a51cf162cb4cc3060349 Mon Sep 17 00:00:00 2001 From: juliannguyen4 <109386615+juliannguyen4@users.noreply.github.com> Date: Tue, 6 Feb 2024 08:47:04 -0800 Subject: [PATCH 2/8] Also derive Clone trait for OperationBin and OperationData --- src/operations/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/operations/mod.rs b/src/operations/mod.rs index 78869b53..a6e47393 100644 --- a/src/operations/mod.rs +++ b/src/operations/mod.rs @@ -57,6 +57,7 @@ pub enum OperationType { } #[doc(hidden)] +#[derive(Clone)] pub enum OperationData<'a> { None, Value(&'a Value), @@ -68,6 +69,7 @@ pub enum OperationData<'a> { } #[doc(hidden)] +#[derive(Clone)] pub enum OperationBin<'a> { None, All, From 1467a918484072caf843ab3dea070b3ae9de171e Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Tue, 6 Feb 2024 08:53:32 -0800 Subject: [PATCH 3/8] Add Clone trait for other nested types --- src/operations/cdt.rs | 2 ++ src/operations/exp.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/src/operations/cdt.rs b/src/operations/cdt.rs index 55902ac0..efc7083e 100644 --- a/src/operations/cdt.rs +++ b/src/operations/cdt.rs @@ -22,6 +22,7 @@ use crate::operations::cdt_context::CdtContext; use crate::Value; #[doc(hidden)] +#[derive(Clone)] pub enum CdtArgument<'a> { Byte(u8), Int(i64), @@ -35,6 +36,7 @@ pub type OperationEncoder = Box, &CdtOperation, &[CdtContext]) -> Result>; #[doc(hidden)] +#[derive(Clone)] pub struct CdtOperation<'a> { pub op: u8, pub encoder: OperationEncoder, diff --git a/src/operations/exp.rs b/src/operations/exp.rs index 114a6618..9e3caf5a 100644 --- a/src/operations/exp.rs +++ b/src/operations/exp.rs @@ -48,6 +48,7 @@ pub enum ExpWriteFlags { pub type ExpressionEncoder = Box, &ExpOperation) -> Result>; #[doc(hidden)] +#[derive(Clone)] pub struct ExpOperation<'a> { pub encoder: ExpressionEncoder, pub policy: i64, From ae85311a330f40750cbc78e6420d83d3b6862b84 Mon Sep 17 00:00:00 2001 From: juliannguyen4 <109386615+juliannguyen4@users.noreply.github.com> Date: Tue, 6 Feb 2024 12:27:51 -0800 Subject: [PATCH 4/8] Add lifetime annotation to OperationEncoder in CdtOperation struct --- src/operations/cdt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/operations/cdt.rs b/src/operations/cdt.rs index efc7083e..382fc9e8 100644 --- a/src/operations/cdt.rs +++ b/src/operations/cdt.rs @@ -39,7 +39,7 @@ pub type OperationEncoder = #[derive(Clone)] pub struct CdtOperation<'a> { pub op: u8, - pub encoder: OperationEncoder, + pub encoder: OperationEncoder<'a>, pub args: Vec>, } From d7cebeb31aa6f4ced855b515c67b6b4114c85911 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Tue, 6 Feb 2024 12:36:17 -0800 Subject: [PATCH 5/8] Add lifetime annotation to all references in OperationEncoder type alias --- src/operations/cdt.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/operations/cdt.rs b/src/operations/cdt.rs index 382fc9e8..5e7a75f3 100644 --- a/src/operations/cdt.rs +++ b/src/operations/cdt.rs @@ -32,8 +32,8 @@ pub enum CdtArgument<'a> { Map(&'a HashMap), } -pub type OperationEncoder = - Box, &CdtOperation, &[CdtContext]) -> Result>; +pub type OperationEncoder<'a> = + Box, &'a CdtOperation, &'a [CdtContext]) -> Result>; #[doc(hidden)] #[derive(Clone)] From 91cfd63a91231a930bb866b5cc98dee55f0808aa Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Tue, 6 Feb 2024 12:41:10 -0800 Subject: [PATCH 6/8] Revert "Add lifetime annotation to all references in OperationEncoder type alias" This reverts commit d7cebeb31aa6f4ced855b515c67b6b4114c85911. --- src/operations/cdt.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/operations/cdt.rs b/src/operations/cdt.rs index 5e7a75f3..382fc9e8 100644 --- a/src/operations/cdt.rs +++ b/src/operations/cdt.rs @@ -32,8 +32,8 @@ pub enum CdtArgument<'a> { Map(&'a HashMap), } -pub type OperationEncoder<'a> = - Box, &'a CdtOperation, &'a [CdtContext]) -> Result>; +pub type OperationEncoder = + Box, &CdtOperation, &[CdtContext]) -> Result>; #[doc(hidden)] #[derive(Clone)] From ef062d89b65119a61d37534b377407a91d9a6589 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Tue, 6 Feb 2024 12:41:25 -0800 Subject: [PATCH 7/8] Revert "Add lifetime annotation to OperationEncoder in CdtOperation struct" This reverts commit ae85311a330f40750cbc78e6420d83d3b6862b84. --- src/operations/cdt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/operations/cdt.rs b/src/operations/cdt.rs index 382fc9e8..efc7083e 100644 --- a/src/operations/cdt.rs +++ b/src/operations/cdt.rs @@ -39,7 +39,7 @@ pub type OperationEncoder = #[derive(Clone)] pub struct CdtOperation<'a> { pub op: u8, - pub encoder: OperationEncoder<'a>, + pub encoder: OperationEncoder, pub args: Vec>, } From fdb20256e8ce0c67f6742a94ed92de6aaa5cffdd Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Tue, 6 Feb 2024 12:44:36 -0800 Subject: [PATCH 8/8] Attempt to implement Clone trait for Box --- src/operations/cdt.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/operations/cdt.rs b/src/operations/cdt.rs index efc7083e..5bf0fa67 100644 --- a/src/operations/cdt.rs +++ b/src/operations/cdt.rs @@ -35,6 +35,12 @@ pub enum CdtArgument<'a> { pub type OperationEncoder = Box, &CdtOperation, &[CdtContext]) -> Result>; +impl Clone for Box { + fn clone(&self) -> Self { + self.clone_box() + } +} + #[doc(hidden)] #[derive(Clone)] pub struct CdtOperation<'a> {