pub trait DeltaPack: Sized {
// Required methods
fn equals(&self, other: &Self) -> bool;
fn encode_into(&self, encoder: &mut Encoder);
fn decode_from(decoder: &mut Decoder<'_>) -> Self;
fn encode_diff_into(a: &Self, b: &Self, encoder: &mut Encoder);
fn decode_diff_from(obj: &Self, decoder: &mut Decoder<'_>) -> Self;
// Provided methods
fn encode(&self) -> Vec<u8> ⓘ { ... }
fn decode(buf: &[u8]) -> Self { ... }
fn encode_diff(a: &Self, b: &Self) -> Vec<u8> ⓘ { ... }
fn decode_diff(obj: &Self, diff: &[u8]) -> Self { ... }
fn create_sync_session() -> SyncSession<Self>
where Self: Clone { ... }
}Expand description
Common surface shared by every delta-pack-encodable type, whether produced
by the CLI’s Rust codegen or the #[derive(DeltaPack)] proc-macro.
Implementers provide the core serialization primitives (encode_into,
decode_from, the diff _into/_from variants, and equals). The
whole-value entry points (encode, decode, encode_diff, decode_diff)
have default implementations: encode_diff forwards to encode_diff_into,
which is the right shape for enums and unions. Structs override
encode_diff/decode_diff to wrap in push_object_diff /
next_object_diff, since object diffs carry a per-object change bit.
Required Methods§
fn equals(&self, other: &Self) -> bool
fn encode_into(&self, encoder: &mut Encoder)
fn decode_from(decoder: &mut Decoder<'_>) -> Self
fn encode_diff_into(a: &Self, b: &Self, encoder: &mut Encoder)
fn decode_diff_from(obj: &Self, decoder: &mut Decoder<'_>) -> Self
Provided Methods§
fn encode(&self) -> Vec<u8> ⓘ
fn decode(buf: &[u8]) -> Self
fn encode_diff(a: &Self, b: &Self) -> Vec<u8> ⓘ
fn decode_diff(obj: &Self, diff: &[u8]) -> Self
Sourcefn create_sync_session() -> SyncSession<Self>where
Self: Clone,
fn create_sync_session() -> SyncSession<Self>where
Self: Clone,
Construct a SyncSession for this type — the recommended handle for
state sync streams. Only available when Self: Clone, which generated
and #[derive(DeltaPack)] types satisfy by convention.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.