[][src]Enum packs::ll::types::lengths::Length

pub enum Length {
    Tiny(u8),
    Bit8(u8),
    Bit16(u16),
    Bit32(i32),
}

The possible lengths for sized types like String8. The different sign extensions are according to the PackStream specification. This type should be used for encoding any size information, e.g. the 32bit size information of a String32 or Dictionary32 can be encoded using Length:

use packs::ll::types::lengths::Length;
let mut buffer = Vec::with_capacity(4);
Length::Bit32(420420).encode(&mut buffer);

assert_eq!(buffer, vec!(0x00, 0x06, 0x6A, 0x44), "Got: {:X?}", buffer);

It does not shrink the size to any lower space (e.g. using u8 instead of i32).

Variants

Tiny(u8)
Bit8(u8)
Bit16(u16)
Bit32(i32)

Implementations

impl Length[src]

pub fn marker(
    self,
    tiny_marker: fn(_: usize) -> Marker,
    marker8: Marker,
    marker16: Marker,
    marker32: Marker
) -> Marker
[src]

pub fn from_usize(size: usize) -> Option<Length>[src]

pub fn into_usize(self) -> usize[src]

pub fn encode<T: Write>(self, writer: T) -> Result<usize, EncodeError>[src]

Trait Implementations

impl Clone for Length[src]

impl Copy for Length[src]

impl Debug for Length[src]

impl PartialEq<Length> for Length[src]

impl StructuralPartialEq for Length[src]

Auto Trait Implementations

impl RefUnwindSafe for Length

impl Send for Length

impl Sync for Length

impl Unpin for Length

impl UnwindSafe for Length

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, 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.