use crate::{ commands::wrap_command, compression_code::CompressionCode, containers::bitvec::BitVec, macros::wrap_object_attr_wrapped, }; use std::sync::Arc; wrap_command!(BitVecCommand); wrap_object_attr_wrapped!(BitVecCommand, bitvec, BitVec); #[uniffi::export] impl BitVecCommand { #[uniffi::constructor] pub fn new( offset: u64, bitvec: &Arc, compression: CompressionCode, operation: BinaryOperation, ) -> Arc { let offset = offset as usize; let bitvec = bitvec.read().clone(); let compression = compression.into(); let operation = operation.into(); let actual = servicepoint::BitVecCommand { offset, bitvec, compression, operation, }; Self::internal_new(actual) } } #[derive(uniffi::Enum)] pub enum BinaryOperation { Overwrite, And, Or, Xor, } impl From for servicepoint::BinaryOperation { fn from(op: BinaryOperation) -> Self { match op { BinaryOperation::Overwrite => { servicepoint::BinaryOperation::Overwrite } BinaryOperation::And => servicepoint::BinaryOperation::And, BinaryOperation::Or => servicepoint::BinaryOperation::Or, BinaryOperation::Xor => servicepoint::BinaryOperation::Xor, } } }