[−][src]Struct ghakuf::formats::VLQ
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 2^28.
Methods
impl VLQ
[src]
pub fn new(val: u32) -> VLQ
[src]
pub 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]);
pub 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);
pub 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 Clone for VLQ
[src]
fn clone(&self) -> VLQ
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Copy for VLQ
[src]
impl PartialEq<VLQ> for VLQ
[src]
impl Debug for VLQ
[src]
impl Display for VLQ
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,