create separate types per command

This commit is contained in:
Vinzenz Schroeter 2025-06-16 11:32:12 +02:00
parent c29482ac56
commit bffc905261
19 changed files with 306 additions and 200 deletions

52
src/commands/bitvec.rs Normal file
View 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,
}
}
}