Struct ghakuf::formats::VLQ
[−]
[src]
pub struct VLQ { /* fields omitted */ }
A struct representing SMF Variable Length Quantity.
You can make VLQ from u32 value.
Examples
use ghakuf::formats::VLQ; let vlq = VLQ::new(192); assert_eq!(vlq.val(), 192); assert_eq!(vlq.binary(), [0x81, 0x40]); assert_eq!(vlq.len(), 2);
Also you can make VLQ from u8 values.
Examples
use ghakuf::formats::{VLQ, VLQBuilder}; let vlq = VLQBuilder::new() .push(0x86) .push(0xc3) .push(0x17) .build(); assert_eq!(vlq.val(), 106_903); assert_eq!(vlq.binary(), [0x86, 0xc3, 0x17]); assert_eq!(vlq.len(), 3);
Note: Due to SMF restriction, this struct can only represent value under 228.
Methods
impl VLQ
[src]
fn new(val: u32) -> VLQ
[src]
fn binary(&self) -> Vec<u8>
[src]
Makes binary array for SMF.
Examples
use ghakuf::formats::VLQ; let vlq = VLQ::new(192); assert_eq!(vlq.binary(), [0x81, 0x40]);
fn len(&self) -> usize
[src]
Returns length of binary array for SMF.
Examples
use ghakuf::formats::VLQ; let vlq = VLQ::new(192); assert_eq!(vlq.len(), 2);
fn val(&self) -> u32
[src]
Returns value from VLQ.
Examples
use ghakuf::formats::VLQ; let vlq = VLQ::new(192); assert_eq!(vlq.val(), 192);
Trait Implementations
impl PartialEq for VLQ
[src]
fn eq(&self, __arg_0: &VLQ) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &VLQ) -> bool
[src]
This method tests for !=
.
impl Clone for VLQ
[src]
fn clone(&self) -> VLQ
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more