Trait bip_bencode::BConvert [] [src]

pub trait BConvert {
    type Error;
    fn handle_error(&self, error: BencodeConvertError) -> Self::Error;

    fn convert_int<'a, B, E>(
        &self,
        bencode: B,
        error_key: E
    ) -> Result<i64, Self::Error>
    where
        B: BRefAccess<'a>,
        E: AsRef<[u8]>
, { ... } fn convert_bytes<'a, B, E>(
        &self,
        bencode: B,
        error_key: E
    ) -> Result<&'a [u8], Self::Error>
    where
        B: BRefAccess<'a>,
        E: AsRef<[u8]>
, { ... } fn convert_str<'a, B, E>(
        &self,
        bencode: B,
        error_key: E
    ) -> Result<&'a str, Self::Error>
    where
        B: BRefAccess<'a>,
        E: AsRef<[u8]>
, { ... } fn convert_list<'a: 'b, 'b, B, E>(
        &self,
        bencode: &'b B,
        error_key: E
    ) -> Result<&'b BListAccess<B::BType>, Self::Error>
    where
        B: BRefAccess<'a>,
        E: AsRef<[u8]>
, { ... } fn convert_dict<'a, 'b, B, E>(
        &self,
        bencode: &'b B,
        error_key: E
    ) -> Result<&'b BDictAccess<'a, B::BType>, Self::Error>
    where
        B: BRefAccess<'a>,
        E: AsRef<[u8]>
, { ... } fn lookup<'a, 'b, B, K>(
        &self,
        dictionary: &'b BDictAccess<'a, B>,
        key: K
    ) -> Result<&'b B, Self::Error>
    where
        B: BRefAccess<'a>,
        K: AsRef<[u8]>
, { ... } fn lookup_and_convert_int<'a, B, K>(
        &self,
        dictionary: &BDictAccess<'a, B>,
        key: K
    ) -> Result<i64, Self::Error>
    where
        B: BRefAccess<'a>,
        K: AsRef<[u8]>
, { ... } fn lookup_and_convert_bytes<'a, B, K>(
        &self,
        dictionary: &BDictAccess<'a, B>,
        key: K
    ) -> Result<&'a [u8], Self::Error>
    where
        B: BRefAccess<'a>,
        K: AsRef<[u8]>
, { ... } fn lookup_and_convert_str<'a, B, K>(
        &self,
        dictionary: &BDictAccess<'a, B>,
        key: K
    ) -> Result<&'a str, Self::Error>
    where
        B: BRefAccess<'a>,
        K: AsRef<[u8]>
, { ... } fn lookup_and_convert_list<'a, 'b, B, K>(
        &self,
        dictionary: &'b BDictAccess<'a, B>,
        key: K
    ) -> Result<&'b BListAccess<B::BType>, Self::Error>
    where
        B: BRefAccess<'a>,
        K: AsRef<[u8]>
, { ... } fn lookup_and_convert_dict<'a, 'b, B, K>(
        &self,
        dictionary: &'b BDictAccess<'a, B>,
        key: K
    ) -> Result<&'b BDictAccess<'a, B::BType>, Self::Error>
    where
        B: BRefAccess<'a>,
        K: AsRef<[u8]>
, { ... } }

Trait for casting bencode objects and converting conversion errors into application specific errors.

Associated Types

Required Methods

Convert the given conversion error into the appropriate error type.

Provided Methods

Attempt to convert the given bencode value into an integer.

Error key is used to generate an appropriate error message should the operation return an error.

Attempt to convert the given bencode value into bytes.

Error key is used to generate an appropriate error message should the operation return an error.

Attempt to convert the given bencode value into a UTF-8 string.

Error key is used to generate an appropriate error message should the operation return an error.

Attempty to convert the given bencode value into a list.

Error key is used to generate an appropriate error message should the operation return an error.

Attempt to convert the given bencode value into a dictionary.

Error key is used to generate an appropriate error message should the operation return an error.

Look up a value in a dictionary of bencoded values using the given key.

Combines a lookup operation on the given key with a conversion of the value, if found, to an integer.

Combines a lookup operation on the given key with a conversion of the value, if found, to a series of bytes.

Combines a lookup operation on the given key with a conversion of the value, if found, to a UTF-8 string.

Combines a lookup operation on the given key with a conversion of the value, if found, to a list.

Combines a lookup operation on the given key with a conversion of the value, if found, to a dictionary.

Implementors