[−][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.
Implementations
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]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
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, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,