move containers to module
This commit is contained in:
parent
4cbf3784fc
commit
227db03d23
8 changed files with 35 additions and 37 deletions
40
src/containers/brightness_grid.rs
Normal file
40
src/containers/brightness_grid.rs
Normal 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()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue