0.3.4-alpha.2

This commit is contained in:
2026-09-21 17:21:25 +02:00
parent 27978c3782
commit 4e2be3cc9a
11 changed files with 533 additions and 8 deletions

View File

@@ -0,0 +1,49 @@
// file: crates/common/game-realtime-transport-lib/src/message.rs
// version: 1
/// Owned opaque binary payload carried by a realtime transport.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct TransportMessage {
bytes: Vec<u8>,
}
impl TransportMessage {
/// Creates a transport message from owned bytes.
#[must_use]
pub fn new(bytes: Vec<u8>) -> Self {
return Self { bytes };
}
/// Borrows the opaque payload bytes.
#[must_use]
pub fn as_bytes(&self) -> &[u8] {
return self.bytes.as_slice();
}
/// Consumes the message and returns its owned payload bytes.
#[must_use]
pub fn into_bytes(self) -> Vec<u8> {
return self.bytes;
}
/// Returns whether the payload is empty.
#[must_use]
pub fn is_empty(&self) -> bool {
return self.bytes.is_empty();
}
/// Returns the payload length in bytes.
#[must_use]
pub fn len(&self) -> usize {
return self.bytes.len();
}
}
/// Outcome of one successful transport receive operation.
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum TransportReceive {
/// One opaque binary message was received.
Message(crate::TransportMessage),
/// The remote peer completed a clean transport-level close.
Closed,
}