hopr_primitive_types

Module traits

Source
Expand description

Defines commonly used traits across the entire code base.

Traitsยง

AsUnixTimestamp
A trait that adds extension method to represent a time object as Duration since Unix epoch.
BytesEncodable
Represents a type that can be encoded to/decoded from a fixed sized byte array of size N. This requires processing and memory allocation to represent the type in binary encoding.
BytesRepresentable
Represents a type that is already internally represented by a fixed size byte array, and therefore requires no memory allocation to represent the type in binary encoding.
IntoEndian
Extension trait for fixed size numbers to allow conversion to/from endian representations.
SaturatingSub
A trait that adds extension method to perform saturated substractions on SystemTime instances.
ToHex
A generic type that can be converted to a hexadecimal string.
UnitaryFloatOps
Allows type to be multiplied and divided by a float in range [0.0, 1.0].