Skip to content

Derive Clone trait for Operation struct #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
8 changes: 8 additions & 0 deletions src/operations/cdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -34,7 +35,14 @@ pub enum CdtArgument<'a> {
pub type OperationEncoder =
Box<dyn Fn(&mut Option<&mut Buffer>, &CdtOperation, &[CdtContext]) -> Result<usize>>;

impl Clone for Box<dyn OperationEncoder> {
fn clone(&self) -> Self {
self.clone_box()
}
}

#[doc(hidden)]
#[derive(Clone)]
pub struct CdtOperation<'a> {
pub op: u8,
pub encoder: OperationEncoder,
Expand Down
1 change: 1 addition & 0 deletions src/operations/exp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub enum ExpWriteFlags {
pub type ExpressionEncoder = Box<dyn Fn(&mut Option<&mut Buffer>, &ExpOperation) -> Result<usize>>;

#[doc(hidden)]
#[derive(Clone)]
pub struct ExpOperation<'a> {
pub encoder: ExpressionEncoder,
pub policy: i64,
Expand Down
3 changes: 3 additions & 0 deletions src/operations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub enum OperationType {
}

#[doc(hidden)]
#[derive(Clone)]
pub enum OperationData<'a> {
None,
Value(&'a Value),
Expand All @@ -68,13 +69,15 @@ pub enum OperationData<'a> {
}

#[doc(hidden)]
#[derive(Clone)]
pub enum OperationBin<'a> {
None,
All,
Name(&'a str),
}

/// 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)]
Expand Down