mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-06-28 08:49:38 -04:00
8900131b7d
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
24 lines
594 B
Rust
24 lines
594 B
Rust
use spacetimedb_sats::buffer::BufWriter;
|
|
|
|
/// A commitlog payload consisting of uninterpreted bytes.
|
|
pub struct Payload(Box<[u8]>);
|
|
|
|
impl Payload {
|
|
pub fn new(bytes: impl Into<Box<[u8]>>) -> Self {
|
|
Self(bytes.into())
|
|
}
|
|
}
|
|
|
|
impl spacetimedb_commitlog::Encode for Payload {
|
|
fn encode_record<W: BufWriter>(&self, writer: &mut W) {
|
|
writer.put_u64(self.0.len() as _);
|
|
writer.put_slice(&self.0[..]);
|
|
}
|
|
}
|
|
|
|
impl spacetimedb_commitlog::Encode for &Payload {
|
|
fn encode_record<W: BufWriter>(&self, writer: &mut W) {
|
|
(*self).encode_record(writer)
|
|
}
|
|
}
|