mod shm; use shared_mem_queue::byte_queue::ByteQueue; use shared_mem_queue::msg_queue::MsgQueue; use shm::ShmHandle; use libc::O_RDWR; const SHM_MODE_WR: libc::mode_t = 0; const SHM_NAME_WR: &str = "shm_msg_queue"; const SHM_SIZE: usize = 128; const RX_BUF_SIZE: usize = 32; fn main() { let mut shm_handle = ShmHandle::new(SHM_NAME_WR, SHM_SIZE, O_RDWR, SHM_MODE_WR).unwrap(); let prefix: &[u8] = &[7, 7, 7, 7]; let rx_buf: [u8; RX_BUF_SIZE] = [0; RX_BUF_SIZE]; let mut msg_queue = MsgQueue::new( unsafe { ByteQueue::attach(shm_handle.as_mut_ptr_u8(), SHM_SIZE) }, prefix, rx_buf, ); loop { match msg_queue.read_blocking() { Ok(msg_slice) => println!("{:?}", msg_slice), Err(err) => println!("{:?}", err), } } }