[][src]Enum bt_bencode::Value

pub enum Value {
    ByteStr(ByteBuf),
    Int(Number),
    List(Vec<Value>),
    Dict(BTreeMap<ByteBuf, Value>),
}

Represents a valid Bencode value.

It is useful when it is unknown what the data may contain (e.g. when different kinds of messages can be received in a network packet).

Variants

ByteStr(ByteBuf)

A byte string.

Encoded strings can contain non-UTF-8 bytes, so a byte string is used to represent "strings".

Int(Number)

An integer which can be signed or unsigned.

List(Vec<Value>)

A list of values.

A dictionary of values.

Methods

impl Value[src]

pub fn as_byte_str(&self) -> Option<&ByteBuf>[src]

pub fn as_byte_str_mut(&mut self) -> Option<&mut ByteBuf>[src]

pub fn as_str(&self) -> Option<&str>[src]

pub fn as_str_mut(&mut self) -> Option<&mut str>[src]

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

pub fn as_i64(&self) -> Option<i64>[src]

pub fn as_array(&self) -> Option<&Vec<Value>>[src]

pub fn as_array_mut(&mut self) -> Option<&mut Vec<Value>>[src]

pub fn as_dict(&self) -> Option<&BTreeMap<ByteBuf, Value>>[src]

pub fn as_dict_mut(&mut self) -> Option<&mut BTreeMap<ByteBuf, Value>>[src]

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

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

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

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

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

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

impl Value[src]

pub fn get<I: Index>(&self, index: I) -> Option<&Value>[src]

pub fn get_mut<I: Index>(&mut self, index: I) -> Option<&mut Value>[src]

Trait Implementations

impl Clone for Value[src]

impl Debug for Value[src]

impl<'de> Deserialize<'de> for Value[src]

impl<'de> Deserializer<'de> for Value[src]

type Error = Error

The error type that can be returned if some error occurs during deserialization. Read more

impl<'a> From<&'a str> for Value[src]

impl<K: Into<ByteBuf>, V: Into<Value>> From<BTreeMap<K, V>> for Value[src]

impl From<String> for Value[src]

impl<V: Into<Value>> From<Vec<V>> for Value[src]

impl From<i16> for Value[src]

impl From<i32> for Value[src]

impl From<i64> for Value[src]

impl From<i8> for Value[src]

impl From<isize> for Value[src]

impl From<u16> for Value[src]

impl From<u32> for Value[src]

impl From<u64> for Value[src]

impl From<u8> for Value[src]

impl From<usize> for Value[src]

impl FromStr for Value[src]

type Err = Error

The associated error which can be returned from parsing.

impl<I> Index<I> for Value where
    I: Index
[src]

type Output = Value

The returned type after indexing.

impl<I> IndexMut<I> for Value where
    I: Index
[src]

impl<'de> IntoDeserializer<'de, Error> for Value[src]

type Deserializer = Self

The type of the deserializer being converted into.

impl PartialEq<Value> for Value[src]

impl Serialize for Value[src]

impl StructuralPartialEq for Value[src]

Auto Trait Implementations

impl RefUnwindSafe for Value

impl Send for Value

impl Sync for Value

impl Unpin for Value

impl UnwindSafe for Value

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> DeserializeOwned for T where
    T: Deserialize<'de>, 
[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.