pub enum OwnedValue {
Integer(i64),
IntegerBytes(Vec<u8>),
Bytes(Vec<u8>),
List(Vec<Self>),
Dictionary(BTreeMap<Vec<u8>, Self>),
}Expand description
An owned bencode value that serializes canonically.
Variants§
Integer(i64)
Signed bencode integer.
IntegerBytes(Vec<u8>)
Arbitrary-precision canonical signed decimal bytes.
Bytes(Vec<u8>)
Raw byte string.
List(Vec<Self>)
Ordered list of values.
Dictionary(BTreeMap<Vec<u8>, Self>)
Dictionary stored in canonical raw-byte key order.
Implementations§
Source§impl OwnedValue
impl OwnedValue
Sourcepub fn integer_bytes(value: impl AsRef<[u8]>) -> Result<Self>
pub fn integer_bytes(value: impl AsRef<[u8]>) -> Result<Self>
Creates an arbitrary-precision canonical integer.
§Errors
Returns a canonical error for empty digits, non-digits, a plus sign, leading zeroes, or negative zero.
Sourcepub fn list(values: impl IntoIterator<Item = Self>) -> Self
pub fn list(values: impl IntoIterator<Item = Self>) -> Self
Creates a list value.
Sourcepub fn dictionary(
entries: impl IntoIterator<Item = (Vec<u8>, Self)>,
) -> Result<Self>
pub fn dictionary( entries: impl IntoIterator<Item = (Vec<u8>, Self)>, ) -> Result<Self>
Creates a dictionary and rejects duplicate raw byte keys.
§Errors
Returns a canonical error if the input contains duplicate keys.
Sourcepub fn encoded_len(&self) -> usize
pub fn encoded_len(&self) -> usize
Returns the exact canonical encoded length.
Trait Implementations§
Source§impl Clone for OwnedValue
impl Clone for OwnedValue
Source§fn clone(&self) -> OwnedValue
fn clone(&self) -> OwnedValue
Returns a duplicate 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 Debug for OwnedValue
impl Debug for OwnedValue
Source§impl PartialEq for OwnedValue
impl PartialEq for OwnedValue
impl Eq for OwnedValue
impl StructuralPartialEq for OwnedValue
Auto Trait Implementations§
impl Freeze for OwnedValue
impl RefUnwindSafe for OwnedValue
impl Send for OwnedValue
impl Sync for OwnedValue
impl Unpin for OwnedValue
impl UnwindSafe for OwnedValue
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