pub mod host; pub mod manager; pub mod output; pub use manager::*; type MaskMessage = (u64, u32, Vec); type RowMessage = (u64, Vec>); pub enum Message { CheckRequest(CheckRequest), HostMessage(MaskMessage), OutputMessage(RowMessage), ResultMessage(ResultMessage), Terminate, } pub struct ResultMessage { data: Vec, offset: usize, size: usize, wg_size: usize, id: u64, } impl ResultMessage { fn new(data: Vec, offset: usize, size: usize, wg_size: usize, id: u64) -> Self { Self { data, offset, size, wg_size, id, } } fn valid_walls(&self) -> Vec> { let mut result = vec![Vec::new(); self.wg_size]; for (j, r) in self.data.iter().enumerate() { for b in 0..64 { if r & (1 << b) != 0 { let permutation = j / self.size + self.offset; let instruction = (j % self.size) * 64 + b; result[instruction].push(permutation as u32); } } } result } } pub struct CheckRequest { rows: Vec, bitmask: u64, queue: u32, } impl CheckRequest { pub fn new(rows: Vec, bitmask: u64, queue: u32) -> Self { Self { rows, bitmask, queue, } } }