pub enum Bencode {
Int(i64),
Str(Vec<u8>),
List(Vec<Bencode>),
Dict(HashMap<String, Bencode>),
}
Expand description
Represents a bencode value.
Variants§
Int(i64)
Represents an integer value.
Str(Vec<u8>)
Represents a string value.
List(Vec<Bencode>)
Represents a list of bencode values.
Dict(HashMap<String, Bencode>)
Represents a dictionary of bencode values.
Implementations§
Source§impl Bencode
impl Bencode
Sourcepub fn as_int(&self) -> Option<i64>
pub fn as_int(&self) -> Option<i64>
Returns the integer value if this is a Bencode::Int
.
§Returns
An Option
containing the integer value or None
if this is not a Bencode::Int
.
Sourcepub fn as_bytes(&self) -> Option<&Vec<u8>>
pub fn as_bytes(&self) -> Option<&Vec<u8>>
Returns the string value if this is a Bencode::Str
.
§Returns
An Option
containing the string value or None
if this is not a Bencode::Str
.
Trait Implementations§
impl Eq for Bencode
impl StructuralPartialEq for Bencode
Auto Trait Implementations§
impl Freeze for Bencode
impl RefUnwindSafe for Bencode
impl Send for Bencode
impl Sync for Bencode
impl Unpin for Bencode
impl UnwindSafe for Bencode
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