[][src]Enum bytecodec::ByteCount

pub enum ByteCount {
    Finite(u64),
    Infinite,
    Unknown,
}

Number of bytes of interest.

Variants

Finite(u64)
Infinite
Unknown

Methods

impl ByteCount[src]

pub fn is_finite(&self) -> bool[src]

Returns true if this is ByteCount::Finite(_), otherwise false.

pub fn is_infinite(&self) -> bool[src]

Returns true if this is ByteCount::Infinite, otherwise false.

pub fn is_unknow(&self) -> bool[src]

Returns true if this is ByteCount::Unknown, otherwise false.

pub fn to_u64(&self) -> Option<u64>[src]

Tries to convert this ByteCount to an u64 value.

If it is not a ByteCount::Finite(_),None will be returned.

pub fn add_for_decoding(self, other: Self) -> Self[src]

Adds two ByteCount instances for decoding (i.e., Decode::requiring_bytes method).

Rule

Finite(a) + Finite(b) = Finite(a + b)
Infinite  + _         = Infinite
_         + Infinite  = Infinite
Unknown   + Unknown   = Unknown
Finite(0) + Unknown   = Unknown
Unknown   + Finite(0) = Unknown
Finite(a) + Unknown   = Finite(a)
Unknown   + Finite(b) = Finite(b)

pub fn add_for_encoding(self, other: Self) -> Self[src]

Adds two ByteCount instances for encoding (i.e., Encode::requiring_bytes method).

Rule

Finite(a) + Finite(b) = Finite(a + b)
Infinite  + _         = Infinite
_         + Infinite  = Infinite
Unknown   + _         = Unknown
_         + Unknown   = Unknown

Trait Implementations

impl Eq for ByteCount[src]

impl Default for ByteCount[src]

fn default() -> Self[src]

Returns ByteCount::Unknown as the default value.

impl Clone for ByteCount[src]

impl PartialOrd<ByteCount> for ByteCount[src]

impl PartialEq<ByteCount> for ByteCount[src]

impl Copy for ByteCount[src]

impl Hash for ByteCount[src]

impl Debug for ByteCount[src]

Auto Trait Implementations

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

impl<T> From<T> for T[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.

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

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

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