Crate skrillax_serde

source ·
Expand description

skrillax-serde provides definitions for serialization/deserialization of data structures used in Silkroad Online.

Generally, you won’t be implementing the traits provided here, but will be automatically deriving these instead. We provide three traits: Serialize, Deserialize, and ByteSize, for serializing, deserializing, and estimating the size respectively.

Re-exports§

Modules§

Structs§

  • A date time for Silkroad Online, which assumes the time is after 2000-01-01 00:00. This time should only be used as a representation for time to be serialized/deserialized and not for actual timekeeping. Instead, use the From/Deref traits to convert to or from this type right before or after transferring it over the network. This is essentially just a newtype around the chrono::DateTime type.

Traits§

  • An item having a ByteSize implementation specifies it has a known size, independent of if it’s Sized or not. The size reported by ByteSize may sometimes not be the same as std::mem::size_of, as alignment should not be taken into account for ByteSize. The size returned should not be taken as an exact value, though it should always match the final size. Assume this to be a good estimate instead.
  • Deserialize allows an item to be created from a binary representation. Given that there are many different ways such a conversion may fail, this operation will always yield a Result. It is not even sure that there are enough bytes available to be read for the deserialization of this item to completed successfully.
  • The Serialize trait allows an item to be serialized into a binary representation of itself, which may then be used send it off over the network. This trait requires the ByteSize trait to also be present in order to pre-allocate the necessary amount of space for the serialized data.