pub struct BString { /* private fields */ }Expand description
Struct for representing string (byte sequence) in Bencode format.
Implementations§
Trait Implementations§
Source§impl BElement<BString> for BString
impl BElement<BString> for BString
Source§fn decode(encoded: &[u8]) -> Result<(usize, BString), &'static str>
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"));impl Eq for BString
impl StructuralPartialEq for BString
Auto Trait Implementations§
impl Freeze for BString
impl RefUnwindSafe for BString
impl Send for BString
impl Sync for BString
impl Unpin for BString
impl UnwindSafe for BString
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more