Index Mathematics Conjectures nbv lettuce Widgets

typed_lex_width

stdlib/typed/typed_lex_width.nbv

typed_lex_width(static t, static n)

Byte width of a field of a typed byte string in anondb's lexicographic encoding, fixed width types only. Tags as in typed_width: 0 bool, 1 u8, 2 u16, 3 u32, 4 u64, 5 u128 (big-endian, n must be 0) and 8 byte array (n bytes). Bytes (6) and options (7) have no fixed width and are rejected.

Precompiles
assert_eq!, assert_lt!, assert_ne!, if_eq!, if_lt!
Used by
typed/typed_lex_chacha, typed/typed_lex_check

Source

# Byte width of a field of a typed byte string in anondb's lexicographic
# encoding, fixed width types only. Tags as in typed_width: 0 bool, 1 u8,
# 2 u16, 3 u32, 4 u64, 5 u128 (big-endian, `n` must be 0) and 8 byte array
# (`n` bytes). Bytes (6) and options (7) have no fixed width and are
# rejected.
(static t, static n)

assert_lt! t, 9
assert_ne! t, 6, "bytes fields have no fixed width"
assert_ne! t, 7, "options have no fixed width"
static mut w = n
if_lt! t, 6 {
  assert_eq! n, 0
}
if_lt! t, 2 {
  w = 1
}
if_eq! t, 2 {
  w = 2
}
if_eq! t, 3 {
  w = 4
}
if_eq! t, 4 {
  w = 8
}
if_eq! t, 5 {
  w = 16
}
w