[][src]Struct ghakuf::formats::VLQ

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 2^28.

Methods

impl VLQ[src]

pub fn new(val: u32) -> VLQ[src]

Builds VLQ from u32 value.

Examples

use ghakuf::formats::VLQ;

let vlq: VLQ = VLQ::new(192);

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_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

impl Send for VLQ

impl Sync for VLQ

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]