Struct bencode_decoder::BString [] [src]

pub struct BString { /* fields omitted */ }

Struct for representing string (byte sequence) in Bencode format.

Methods

impl BString
[src]

Simple constructor from array of bytes.

Trait Implementations

impl Eq for BString
[src]

impl PartialEq for BString
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Debug for BString
[src]

Formats the value using the given formatter.

impl BElement<BString> for BString
[src]

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: :, where data - sequence of bytes with corresponding length.

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"));