Trait q_compress::data_types::SignedLike
source · pub trait SignedLike: NumberLike<Signed = Self> {
const ZERO: Self;
// Required methods
fn wrapping_add(self, other: Self) -> Self;
fn wrapping_sub(self, other: Self) -> Self;
}
Expand description
Trait for data types that behave like signed integers.
This is used for delta encoding/decoding; i.e. the difference
between consecutive numbers must be a SignedLike
.
For example,
- The deltas between consecutive
u64
s arei64
. - The deltas between consecutive
i64
s arei64
. - The deltas between consecutive timestamps are
i128
. - The deltas between consecutive
bool
s arebool
s (basically 1 bit signed integers under XOR).
This is important because deltas like +1 and -1 are numerically close to
each other and easily compressible, which would not be the case with
unsigned integers.
Note: API stability of SignedLike
is not guaranteed.