pub enum BencodeItemView<'a> {
Integer(i64),
ByteString(&'a [u8]),
List(Vec<BencodeItemView<'a>>),
Dictionary(BTreeMap<&'a [u8], BencodeItemView<'a>>),
}
Expand description
Representation of bencode blobs as a tree. The lifetime is tied to the text in memory, achieving almost zero copy. This is perhaps unsuitable for large bencode blobs since the entire blob may not fit inside the memory.
An owned version is on the agenda but I can’t be bothered right now.
Variants§
Integer(i64)
Bencode integers are represented as i64 for now, technically this is not to specification since no range limit is specified in the bencode document.
ByteString(&'a [u8])
Bencode strings are not guaranteed to be UTF-8, thus using a byte slice
List(Vec<BencodeItemView<'a>>)
Bencode lists, note lists may not be homogeneous
Dictionary(BTreeMap<&'a [u8], BencodeItemView<'a>>)
Bencode dictionary, note lists may not be homogeneous. Bencode dictionary by specification must be lexicographically sorted, BTree preserves ordering
Trait Implementations§
Source§impl<'a> Clone for BencodeItemView<'a>
impl<'a> Clone for BencodeItemView<'a>
Source§fn clone(&self) -> BencodeItemView<'a>
fn clone(&self) -> BencodeItemView<'a>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'a> Debug for BencodeItemView<'a>
impl<'a> Debug for BencodeItemView<'a>
Source§impl<'a> Hash for BencodeItemView<'a>
impl<'a> Hash for BencodeItemView<'a>
Source§impl<'a> Ord for BencodeItemView<'a>
impl<'a> Ord for BencodeItemView<'a>
Source§fn cmp(&self, other: &BencodeItemView<'a>) -> Ordering
fn cmp(&self, other: &BencodeItemView<'a>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'a> PartialEq for BencodeItemView<'a>
impl<'a> PartialEq for BencodeItemView<'a>
Source§impl<'a> PartialOrd for BencodeItemView<'a>
impl<'a> PartialOrd for BencodeItemView<'a>
impl<'a> Eq for BencodeItemView<'a>
impl<'a> StructuralPartialEq for BencodeItemView<'a>
Auto Trait Implementations§
impl<'a> Freeze for BencodeItemView<'a>
impl<'a> RefUnwindSafe for BencodeItemView<'a>
impl<'a> Send for BencodeItemView<'a>
impl<'a> Sync for BencodeItemView<'a>
impl<'a> Unpin for BencodeItemView<'a>
impl<'a> UnwindSafe for BencodeItemView<'a>
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