pub enum Integer {
U5(ZeroTo23),
U8(u8),
U16(u16),
U32(u32),
U64(u64),
N5(ZeroTo23),
N8(u8),
N16(u16),
N32(u32),
N64(u64),
}Expand description
CBOR Integer type
use cbor_tools::{CborType, Integer, Encode};
let val = Integer::from(123);
// This is the CBOR encoding for an 8-bit integer.
assert_eq!(CborType::from(val).encode(), vec![0x18, 0x7B]);CBOR integers will be represented in “canonical” form if the
From<u8 | u32 | u64> impls are used. Non-canonical forms can
be created by initializing the struct directly:
let val = Integer::U32(100);
assert_eq!(CborType::from(val).encode(), vec![0x1a, 0, 0, 0, 0x64]);Note: integers outside the range of [-2^64, 2^64-1] should be encoded as byte strings instead.
Variants§
U5(ZeroTo23)
A value between 0 and 23.
U8(u8)
An 8-bit non-negative integer.
U16(u16)
A 16-bit non-negative integer.
U32(u32)
A 32-bit non-negative integer.
U64(u64)
A 64-bit non-negative integer
N5(ZeroTo23)
A small negative integer (between -1 and -24)
N8(u8)
An 8-bit negative integer.
N16(u16)
A 16-bit negative integer.
N32(u32)
A 32-bit negative integer.
N64(u64)
A 64-bit negative integer.
Trait Implementations§
impl StructuralPartialEq for Integer
Auto Trait Implementations§
impl Freeze for Integer
impl RefUnwindSafe for Integer
impl Send for Integer
impl Sync for Integer
impl Unpin for Integer
impl UnwindSafe for Integer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more