[−][src]Enum ben::Encoder
Encoder to use for encoding data into bencode format.
Variants
Int(i64)
List(Vec<Self>)
Methods
impl Encoder
[src]
pub fn to_vec(&self) -> Vec<u8>
[src]
Encodes data into a vector of bencoded bytes.
Examples:
Basic usage:
use ben::Encoder; let enc = Encoder::from(vec![Encoder::from("Hello"), Encoder::from("World")]); let bytes = enc.to_vec(); assert_eq!(b"l5:Hello5:Worlde", &bytes[..]);
pub fn write<W: Write>(&self, w: &mut W) -> Result<()>
[src]
Encodes and writes the data into given Write
object.
Examples:
Basic usage:
use ben::Encoder; let mut bytes = vec![]; let enc = Encoder::from(vec![Encoder::from("Hello"), Encoder::from("World")]); enc.write(&mut bytes).unwrap(); assert_eq!(b"l5:Hello5:Worlde", &bytes[..]);
Trait Implementations
impl Clone for Encoder
[src]
impl Debug for Encoder
[src]
impl<'_> From<&'_ [u8]> for Encoder
[src]
impl<'_> From<&'_ str> for Encoder
[src]
impl From<BTreeMap<&'static str, Encoder>> for Encoder
[src]
impl From<String> for Encoder
[src]
impl From<Vec<Encoder>> for Encoder
[src]
impl From<Vec<u8>> for Encoder
[src]
impl From<i64> for Encoder
[src]
impl PartialEq<Encoder> for Encoder
[src]
impl PartialOrd<Encoder> for Encoder
[src]
fn partial_cmp(&self, other: &Encoder) -> Option<Ordering>
[src]
fn lt(&self, other: &Encoder) -> bool
[src]
fn le(&self, other: &Encoder) -> bool
[src]
fn gt(&self, other: &Encoder) -> bool
[src]
fn ge(&self, other: &Encoder) -> bool
[src]
impl StructuralPartialEq for Encoder
[src]
Auto Trait Implementations
impl RefUnwindSafe for Encoder
impl Send for Encoder
impl Sync for Encoder
impl Unpin for Encoder
impl UnwindSafe for Encoder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,