create separate types per command
This commit is contained in:
parent
c29482ac56
commit
bffc905261
19 changed files with 306 additions and 200 deletions
52
src/commands/bitvec.rs
Normal file
52
src/commands/bitvec.rs
Normal file
|
@ -0,0 +1,52 @@
|
|||
use crate::{
|
||||
commands::wrap_command, compression_code::CompressionCode,
|
||||
containers::bitvec::BitVec, macros::wrap_object,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
wrap_object!(BitVecCommand);
|
||||
wrap_command!(BitVecCommand);
|
||||
|
||||
#[uniffi::export]
|
||||
impl BitVecCommand {
|
||||
#[uniffi::constructor]
|
||||
pub fn new(
|
||||
offset: u64,
|
||||
bitvec: &Arc<BitVec>,
|
||||
compression: CompressionCode,
|
||||
operation: BinaryOperation,
|
||||
) -> Arc<Self> {
|
||||
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<BinaryOperation> 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,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue