[][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.

Implementations

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]

impl Copy for VLQ[src]

impl Debug for VLQ[src]

impl Display for VLQ[src]

impl PartialEq<VLQ> for VLQ[src]

impl StructuralPartialEq for VLQ[src]

Auto Trait Implementations

impl RefUnwindSafe for VLQ

impl Send for VLQ

impl Sync for VLQ

impl Unpin for VLQ

impl UnwindSafe for VLQ

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

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

type Owned = T

The resulting type after obtaining ownership.

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.