Struct bencode_decoder::BString
[−]
[src]
pub struct BString { /* fields omitted */ }
Struct for representing string (byte sequence) in Bencode format.
Methods
impl BString
[src]
Trait Implementations
impl Eq for BString
[src]
impl PartialEq for BString
[src]
fn eq(&self, __arg_0: &BString) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &BString) -> bool
This method tests for !=
.
impl Debug for BString
[src]
impl BElement<BString> for BString
[src]
fn decode(encoded: &[u8]) -> Result<(usize, BString), &'static str>
Decodes BString
from array of bytes.
Returns Ok((position of last used byte in passed array, parsed BString))
or Err
if couldn't parse BString
correctly.
Examples
BString
must have following structure:
use bencode_decoder::BElement; use bencode_decoder::BString; assert_eq!((4, BString::new("abc".as_bytes())), BString::decode("3:abc".as_bytes()).ok().expect("invalid"));