bytesLength method

int? bytesLength(
  1. int value, {
  2. CborLengthEncoding lengthEncdoing = CborLengthEncoding.canonical,
})

Implementation

int? bytesLength(
  int value, {
  CborLengthEncoding lengthEncdoing = CborLengthEncoding.canonical,
}) {
  if (value < 24 && lengthEncdoing == CborLengthEncoding.canonical) {
    return null;
  } else if (value <= BinaryOps.mask8) {
    return NumBytes.one;
  } else if (value <= BinaryOps.mask16) {
    return NumBytes.two;
  } else if (value <= BinaryOps.mask32) {
    return NumBytes.four;
  } else {
    return NumBytes.eight;
  }
}