Module grin_core::ser

source ·
Expand description

Serialization and deserialization layer specialized for binary encoding. Ensures consistency and safety. Basically a minimal subset or rustc_serialize customized for our need.

To use it simply implement Writeable or Readable and then use the serialize or deserialize functions on them as appropriate.

Structs§

  • Utility to read from a binary source
  • Utility wrapper for an underlying byte Writer. Defines higher level methods to write numbers, byte vectors, hashes, etc.
  • Protocol version-aware wrapper around a Buf impl
  • Reader that exposes an Iterator interface.
  • Protocol version for serialization/deserialization. Note: This is used in various places including but limited to the p2p layer and our local db storage layer. We may speak multiple versions to various peers and a potentially different version for our local db.
  • A reader that reads straight off a stream. Tracks total bytes read so we can verify we read the right number afterwards.

Enums§

  • Signal to a deserializable object how much of its data should be deserialized
  • Possible errors deriving from serializing or deserializing.
  • Signal to a serializable object how much of its data should be serialized

Traits§

  • Generic trait to ensure PMMR elements can be hashed with an index
  • Trait for types that can be added to a PMMR.
  • Trait that every type that can be deserialized from binary must implement. Reads directly to a Reader, a utility type thinly wrapping an underlying Read implementation.
  • Implementations defined how different numbers and binary structures are read from an underlying stream or container (depending on implementation).
  • Collections of items must be sorted lexicographically and all unique.
  • Trait that every type that can be serialized as binary must implement. Writes directly to a Writer, a utility type thinly wrapping an underlying Write implementation.
  • Implementations defined how different numbers and binary structures are written to an underlying stream or container (depending on implementation).

Functions§

  • Deserializes a Readable from any std::io::Read implementation.
  • Deserialize a Readable based on our default “local” protocol version.
  • Reads multiple serialized items into a Vec.
  • Utility function to serialize a writeable directly in memory using a Vec.
  • Serializes a Writeable into any std::io::Write implementation.
  • Serialize a Writeable according to our default “local” protocol version.