pub enum IntByteRepr {
SingleOctet([u8; 2]),
FourOctets([u8; 5]),
}Expand description
Represents the different byte encodings of a 32-bit signed signed.
The enum provides two encoding formats for signed integers:
SingleOctet: For values between -128 and 127 (inclusive)FourOctets: For all other i32 values
Each format includes a format identifier byte followed by the value:
[0x54, x]for single-octet values where x is in two’s complement[0x71, x1, x2, x3, x4]for four-octet values in big-endian format
§Examples
use flederfuchs_amqp::IntByteRepr;
// Small positive number (127)
let max_small = IntByteRepr::SingleOctet([0x54, 0x7F]);
// Small negative number (-128)
let min_small = IntByteRepr::SingleOctet([0x54, 0x80]);
// Large positive number (1_000_000)
let large = IntByteRepr::FourOctets([0x71, 0x00, 0x0F, 0x42, 0x40]);
// Large negative number (-1_000_000)
let neg_large = IntByteRepr::FourOctets([0x71, 0xFF, 0xF0, 0xBD, 0xC0]);Variants§
SingleOctet([u8; 2])
Single-octet encoding for values between -128 and 127.
Format: [0x54, value] where:
0x54is the format identifiervalueis the signed byte in two’s complement representation
§Examples
use flederfuchs_amqp::IntByteRepr;
// Encoding 127
let max_positive = IntByteRepr::SingleOctet([0x54, 0x7F]);
// Encoding -128
let min_negative = IntByteRepr::SingleOctet([0x54, 0x80]);
// Encoding 0
let zero = IntByteRepr::SingleOctet([0x54, 0x00]);FourOctets([u8; 5])
Four-octet encoding for values outside the -128 to 127 range.
Format: [0x71, b1, b2, b3, b4] where:
0x71is the format identifierb1..b4are the four bytes of the signed in big-endian order
§Examples
use flederfuchs_amqp::IntByteRepr;
// Encoding 1_000_000
let large_positive = IntByteRepr::FourOctets([0x71, 0x00, 0x0F, 0x42, 0x40]);
// Encoding -1_000_000
let large_negative = IntByteRepr::FourOctets([0x71, 0xFF, 0xF0, 0xBD, 0xC0]);
// Encoding i32::MAX
let max_int = IntByteRepr::FourOctets([0x71, 0x7F, 0xFF, 0xFF, 0xFF]);Trait Implementations§
Source§impl Clone for IntByteRepr
impl Clone for IntByteRepr
Source§fn clone(&self) -> IntByteRepr
fn clone(&self) -> IntByteRepr
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for IntByteRepr
Source§impl Debug for IntByteRepr
impl Debug for IntByteRepr
impl Eq for IntByteRepr
Source§impl Ord for IntByteRepr
impl Ord for IntByteRepr
Source§fn cmp(&self, other: &IntByteRepr) -> Ordering
fn cmp(&self, other: &IntByteRepr) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for IntByteRepr
impl PartialEq for IntByteRepr
Source§impl PartialOrd for IntByteRepr
impl PartialOrd for IntByteRepr
impl StructuralPartialEq for IntByteRepr
Auto Trait Implementations§
impl Freeze for IntByteRepr
impl RefUnwindSafe for IntByteRepr
impl Send for IntByteRepr
impl Sync for IntByteRepr
impl Unpin for IntByteRepr
impl UnsafeUnpin for IntByteRepr
impl UnwindSafe for IntByteRepr
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