move containers to module

This commit is contained in:
Vinzenz Schroeter 2025-06-13 11:45:11 +02:00
parent 4cbf3784fc
commit 227db03d23
8 changed files with 35 additions and 37 deletions

View file

@ -0,0 +1,40 @@
use crate::macros::*;
use servicepoint::{Brightness, Grid};
use std::{ops::Deref, sync::Arc};
wrap_uniffi_object!(BrightnessGrid);
wrap_width_height!(BrightnessGrid);
wrap_get_set_fill_2d!(BrightnessGrid, Brightness);
#[uniffi::export]
impl BrightnessGrid {
#[uniffi::constructor]
pub fn new(width: u64, height: u64) -> Arc<Self> {
Self::internal_new(servicepoint::BrightnessGrid::new(
width as usize,
height as usize,
))
}
#[uniffi::constructor]
pub fn load(width: u64, height: u64, data: Vec<u8>) -> Arc<Self> {
Self::internal_new(
servicepoint::BrightnessGrid::saturating_load(
width as usize,
height as usize,
&data,
)
.unwrap(),
)
}
pub fn equals(&self, other: &BrightnessGrid) -> bool {
let a = self.actual.read().unwrap();
let b = other.actual.read().unwrap();
*a == *b
}
pub fn copy_raw(&self) -> Vec<u8> {
self.actual.read().unwrap().deref().into()
}
}