[][src]Struct cjdns_bencode::BValue

pub struct BValue(_);

Generic Bencode value.

Implementations

impl BValue[src]

pub fn builder() -> BValueBuilder[src]

Create new BValue using builder.

pub fn decode(data: &[u8]) -> Result<Self, BdecodeError>[src]

Create BValue from bencoded data bytes.

pub fn encode(&self) -> Result<Vec<u8>, BencodeError>[src]

Encode this BValue as bencoded data bytes.

pub fn as_int(&self) -> Result<i64, ()>[src]

Access stored Integer value.

pub fn as_string(&self) -> Result<String, ()>[src]

Access stored bytes value as UTF-8 string.

pub fn as_bytes(&self) -> Result<Vec<u8>, ()>[src]

Access stored bytes value.

pub fn has_dict_entry(&self, key: &str) -> bool[src]

Check whether stored Dict has specified key.

pub fn get_dict_value(&self, key: &str) -> Result<Option<BValue>, ()>[src]

Access stored Dict value by key and return the data under that key.

pub fn get_dict_value_str(&self, key: &str) -> Result<String, ()>[src]

Access stored Dict value by key and return the string data under that key. If key does not exist, or associated value is not string, error is returned.

pub fn get_dict_value_bytes(&self, key: &str) -> Result<Vec<u8>, ()>[src]

Access stored Dict value by key and return the bytes data under that key. If key does not exist, or associated value is not bytes, error is returned.

pub fn delete_dict_value(&mut self, key: &str) -> Result<(), ()>[src]

pub fn set_dict_value(
    &mut self,
    key: &'static str,
    value: BValue
) -> Result<(), ()>
[src]

Trait Implementations

impl Clone for BValue[src]

impl Debug for BValue[src]

impl Eq for BValue[src]

impl PartialEq<BValue> for BValue[src]

impl StructuralEq for BValue[src]

impl StructuralPartialEq for BValue[src]

Auto Trait Implementations

impl RefUnwindSafe for BValue

impl Send for BValue

impl Sync for BValue

impl Unpin for BValue

impl UnwindSafe for BValue

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.