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]

[src]

Builds VLQ from u32 value.

Examples

use ghakuf::formats::VLQ;

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

[src]

Makes binary array for SMF.

Examples

use ghakuf::formats::VLQ;

let vlq = VLQ::new(192);
assert_eq!(vlq.binary(), [0x81, 0x40]);

[src]

Returns length of binary array for SMF.

Examples

use ghakuf::formats::VLQ;

let vlq = VLQ::new(192);
assert_eq!(vlq.len(), 2);

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

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Clone for VLQ
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Copy for VLQ
[src]

impl Debug for VLQ
[src]

[src]

Formats the value using the given formatter.

impl Display for VLQ
[src]

[src]

Formats the value using the given formatter. Read more