Struct DatapackSnapshot
pub struct DatapackSnapshot {
pub session: u64,
pub generation: u64,
pub registries: Vec<DatapackSnapshotRegistry>,
}Expand description
The synchronized registries of a set at one generation, as a server sends them.
Fields§
§session: u64The server’s world session.
generation: u64The generation these entries belong to, from 1.
registries: Vec<DatapackSnapshotRegistry>The registries, sorted by key.
Implementations§
§impl DatapackSnapshot
impl DatapackSnapshot
pub fn encode_offer(
declarations: &[DatapackRegistryDeclaration],
) -> Option<Vec<u8>>
pub fn encode_offer( declarations: &[DatapackRegistryDeclaration], ) -> Option<Vec<u8>>
What a client offers its server: the registries declarations list as synchronized,
with their schemas, as wire bytes.
pub fn decode_offer(
bytes: &[u8],
) -> Result<Vec<DatapackRegistryDeclaration>, DatapackNegotiationError>
pub fn decode_offer( bytes: &[u8], ) -> Result<Vec<DatapackRegistryDeclaration>, DatapackNegotiationError>
Reads a client’s offer, refusing more than MAX_SNAPSHOT_REGISTRIES registries.
pub fn encode(&self) -> Option<Vec<u8>>
pub fn encode(&self) -> Option<Vec<u8>>
The wire bytes, or None when the snapshot is more than MAX_SNAPSHOT_BYTES.
pub fn decode(bytes: &[u8]) -> Result<DatapackSnapshot, DatapackSnapshotError>
pub fn decode(bytes: &[u8]) -> Result<DatapackSnapshot, DatapackSnapshotError>
Reads wire bytes, refusing anything over MAX_SNAPSHOT_BYTES, malformed or with
bytes left over.
pub fn candidate(
&self,
declarations: &[DatapackRegistryDeclaration],
) -> Result<DatapackCandidate, DatapackSnapshotError>
pub fn candidate( &self, declarations: &[DatapackRegistryDeclaration], ) -> Result<DatapackCandidate, DatapackSnapshotError>
Checks the snapshot against this side’s declarations and builds the candidate to
activate: every registry must be one this side declared with the same schema, every
value must fit its field, ids must be valid and unique, references must resolve, and a
registry declared Required must be present. A declared registry the snapshot lacks
(server-only, or optional and not negotiated) stays empty. Nothing is built unless
everything passes.
Trait Implementations§
§impl Clone for DatapackSnapshot
impl Clone for DatapackSnapshot
§fn clone(&self) -> DatapackSnapshot
fn clone(&self) -> DatapackSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more