pub trait BConvert {
type Error;
// Required method
fn handle_error(&self, error: BencodeConvertError) -> Self::Error;
// Provided methods
fn convert_int<B, E>(
&self,
bencode: B,
error_key: E,
) -> Result<i64, Self::Error>
where B: BRefAccess,
E: AsRef<[u8]> { ... }
fn convert_bytes<'a, B, E>(
&self,
bencode: &'a B,
error_key: E,
) -> Result<&'a [u8], Self::Error>
where B: BRefAccess,
E: AsRef<[u8]> { ... }
fn convert_str<'a, B, E>(
&self,
bencode: &'a B,
error_key: E,
) -> Result<&'a str, Self::Error>
where B: BRefAccess,
E: AsRef<[u8]> { ... }
fn convert_list<'a, B, E>(
&self,
bencode: &'a B,
error_key: E,
) -> Result<&'a dyn BListAccess<B::BType>, Self::Error>
where B: BRefAccess,
E: AsRef<[u8]> { ... }
fn convert_dict<'a, B, E>(
&self,
bencode: &'a B,
error_key: E,
) -> Result<&'a dyn BDictAccess<B::BKey, B::BType>, Self::Error>
where B: BRefAccess,
E: AsRef<[u8]> { ... }
fn lookup<'a, B, K1, K2>(
&self,
dictionary: &'a dyn BDictAccess<K1, B>,
key: K2,
) -> Result<&'a B, Self::Error>
where B: BRefAccess,
K2: AsRef<[u8]> { ... }
fn lookup_and_convert_int<B, K1, K2>(
&self,
dictionary: &dyn BDictAccess<K1, B>,
key: K2,
) -> Result<i64, Self::Error>
where B: BRefAccess,
K2: AsRef<[u8]> { ... }
fn lookup_and_convert_bytes<'a, B, K1, K2>(
&self,
dictionary: &'a dyn BDictAccess<K1, B>,
key: K2,
) -> Result<&'a [u8], Self::Error>
where B: BRefAccess,
K2: AsRef<[u8]> { ... }
fn lookup_and_convert_str<'a, B, K1, K2>(
&self,
dictionary: &'a dyn BDictAccess<K1, B>,
key: K2,
) -> Result<&'a str, Self::Error>
where B: BRefAccess,
K2: AsRef<[u8]> { ... }
fn lookup_and_convert_list<'a, B, K1, K2>(
&self,
dictionary: &'a dyn BDictAccess<K1, B>,
key: K2,
) -> Result<&'a dyn BListAccess<B::BType>, Self::Error>
where B: BRefAccess,
K2: AsRef<[u8]> { ... }
fn lookup_and_convert_dict<'a, B, K1, K2>(
&self,
dictionary: &'a dyn BDictAccess<K1, B>,
key: K2,
) -> Result<&'a dyn BDictAccess<B::BKey, B::BType>, Self::Error>
where B: BRefAccess,
K2: AsRef<[u8]> { ... }
}Expand description
Trait for casting bencode objects and converting conversion errors into application specific errors.
Required Associated Types§
Required Methods§
Sourcefn handle_error(&self, error: BencodeConvertError) -> Self::Error
fn handle_error(&self, error: BencodeConvertError) -> Self::Error
Convert the given conversion error into the appropriate error type.
Provided Methods§
Sourcefn convert_int<B, E>(
&self,
bencode: B,
error_key: E,
) -> Result<i64, Self::Error>
fn convert_int<B, E>( &self, bencode: B, error_key: E, ) -> Result<i64, Self::Error>
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.
Sourcefn convert_bytes<'a, B, E>(
&self,
bencode: &'a B,
error_key: E,
) -> Result<&'a [u8], Self::Error>
fn convert_bytes<'a, B, E>( &self, bencode: &'a B, error_key: E, ) -> Result<&'a [u8], Self::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.
Sourcefn convert_str<'a, B, E>(
&self,
bencode: &'a B,
error_key: E,
) -> Result<&'a str, Self::Error>
fn convert_str<'a, B, E>( &self, bencode: &'a B, error_key: E, ) -> Result<&'a str, Self::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.
Sourcefn convert_list<'a, B, E>(
&self,
bencode: &'a B,
error_key: E,
) -> Result<&'a dyn BListAccess<B::BType>, Self::Error>
fn convert_list<'a, B, E>( &self, bencode: &'a B, error_key: E, ) -> Result<&'a dyn BListAccess<B::BType>, Self::Error>
Attempt 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.
Sourcefn convert_dict<'a, B, E>(
&self,
bencode: &'a B,
error_key: E,
) -> Result<&'a dyn BDictAccess<B::BKey, B::BType>, Self::Error>
fn convert_dict<'a, B, E>( &self, bencode: &'a B, error_key: E, ) -> Result<&'a dyn BDictAccess<B::BKey, B::BType>, Self::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.
Sourcefn lookup<'a, B, K1, K2>(
&self,
dictionary: &'a dyn BDictAccess<K1, B>,
key: K2,
) -> Result<&'a B, Self::Error>
fn lookup<'a, B, K1, K2>( &self, dictionary: &'a dyn BDictAccess<K1, B>, key: K2, ) -> Result<&'a B, Self::Error>
Look up a value in a dictionary of bencoded values using the given key.
Sourcefn lookup_and_convert_int<B, K1, K2>(
&self,
dictionary: &dyn BDictAccess<K1, B>,
key: K2,
) -> Result<i64, Self::Error>
fn lookup_and_convert_int<B, K1, K2>( &self, dictionary: &dyn BDictAccess<K1, B>, key: K2, ) -> Result<i64, Self::Error>
Combines a lookup operation on the given key with a conversion of the value, if found, to an integer.
Sourcefn lookup_and_convert_bytes<'a, B, K1, K2>(
&self,
dictionary: &'a dyn BDictAccess<K1, B>,
key: K2,
) -> Result<&'a [u8], Self::Error>
fn lookup_and_convert_bytes<'a, B, K1, K2>( &self, dictionary: &'a dyn BDictAccess<K1, B>, key: K2, ) -> Result<&'a [u8], Self::Error>
Combines a lookup operation on the given key with a conversion of the value, if found, to a series of bytes.
Sourcefn lookup_and_convert_str<'a, B, K1, K2>(
&self,
dictionary: &'a dyn BDictAccess<K1, B>,
key: K2,
) -> Result<&'a str, Self::Error>
fn lookup_and_convert_str<'a, B, K1, K2>( &self, dictionary: &'a dyn BDictAccess<K1, B>, key: K2, ) -> Result<&'a str, Self::Error>
Combines a lookup operation on the given key with a conversion of the value, if found, to a UTF-8 string.
Sourcefn lookup_and_convert_list<'a, B, K1, K2>(
&self,
dictionary: &'a dyn BDictAccess<K1, B>,
key: K2,
) -> Result<&'a dyn BListAccess<B::BType>, Self::Error>
fn lookup_and_convert_list<'a, B, K1, K2>( &self, dictionary: &'a dyn BDictAccess<K1, B>, key: K2, ) -> Result<&'a dyn BListAccess<B::BType>, Self::Error>
Combines a lookup operation on the given key with a conversion of the value, if found, to a list.
Sourcefn lookup_and_convert_dict<'a, B, K1, K2>(
&self,
dictionary: &'a dyn BDictAccess<K1, B>,
key: K2,
) -> Result<&'a dyn BDictAccess<B::BKey, B::BType>, Self::Error>
fn lookup_and_convert_dict<'a, B, K1, K2>( &self, dictionary: &'a dyn BDictAccess<K1, B>, key: K2, ) -> Result<&'a dyn BDictAccess<B::BKey, B::BType>, Self::Error>
Combines a lookup operation on the given key with a conversion of the value, if found, to a dictionary.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.