Rust port of OmniVox, wire-compatible with the C++ original

Byte-exact cereal binary layout, RFC 8439 ChaCha20-Poly1305, RFC 7914
scrypt defaults; tokio transport preserving the original's observable
behavior (contract B1-B3, B5 quirks included). Parity evidence: golden
C++ vectors in tests/vectors.rs and loopback behavior tests; both
cross-directions verified against the unmodified C++ binaries.

Source: https://git.0xfeedc0de.com/michael/OmniVox
This commit is contained in:
2026-09-30 06:35:24 -04:00
commit 268b986bb9
19 changed files with 3042 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
//! Port of the C++ `common.h`: shared payload type and demo constants.
use omnivox::{Cereal, CodecError, Reader, write_byte_vec};
/// Wire-identical to the C++ `DatagramPayload` (cereal field order:
/// `id`, `v1.qword`, `payload`; the `PackedValue64` union only ever
/// serialized its `qword`, so it ports as a plain `u64`).
#[derive(Debug, Default)]
pub struct DatagramPayload {
pub id: u16,
pub v1: u64,
pub payload: Vec<u8>,
}
impl Cereal for DatagramPayload {
fn encode(&self, out: &mut Vec<u8>) {
out.extend_from_slice(&self.id.to_le_bytes());
out.extend_from_slice(&self.v1.to_le_bytes());
write_byte_vec(out, &self.payload);
}
fn decode(bytes: &[u8]) -> Result<Self, CodecError> {
let mut r = Reader::new(bytes);
Ok(Self {
id: r.u16()?,
v1: r.u64()?,
payload: r.byte_vec()?,
})
}
}
pub const PASSWORD: &str = "SecurePassword123";
pub const SALT: &[u8] = &[0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08];
pub const SERVER_PORT: u16 = 8080;
/// Only used by the client example.
#[allow(dead_code)]
pub const SERVER_ADDR: &str = "127.0.0.1";