| Crates.io | xchannel |
| lib.rs | xchannel |
| version | 1.2.0 |
| created_at | 2025-10-29 10:47:33.048597+00 |
| updated_at | 2025-11-22 02:01:56.818642+00 |
| description | mmap-backed IPC channels with regionized layout, alignment-safe headers, and file rolling. |
| homepage | |
| repository | https://github.com/dkumsh/xchannel |
| max_upload_size | |
| id | 1906403 |
| size | 70,402 |
xchannel is a tiny, zero‑copy, mmap‑backed IPC channel format with file rolling.
Channel header; the rest is append‑only.MessageHeader(User) + payload.Skip (pad to next region), Roll (file rolled).use xchannel::{WriterBuilder, ReaderBuilder};
let region = xchannel::page_size(); // ensure page-aligned regions
let mut w = WriterBuilder::new("demo.xch")
.region_size(region)
.file_roll_size(10_000_000)
.build()?;
// write a message
let payload = b"hello world";
if let Some(buf) = w.try_reserve(payload.len()) {
buf.copy_from_slice(payload);
w.commit(1, payload.len() as u32, timestamp)?;
}
// read it back
let mut r = ReaderBuilder::new("demo.xch").late_join().build()?;
if let Some(msg) = r.try_read() {
let hdr = msg.header().unwrap();
println!("type={}, len={}", hdr.message_type, hdr.length);
println!("payload={:?}", msg.payload().unwrap());
}