pub struct BenEncoder<W: Write> { /* private fields */ }Expand description
A struct to make the writing of BEN files easier and more ergonomic.
§Example
use ben::{encode::BenEncoder, BenVariant};
let mut buffer = Vec::new();
let mut ben_encoder = BenEncoder::new(&mut buffer, BenVariant::Standard);
ben_encoder.write_assignment(vec![1, 1, 1, 2, 2, 2]);Implementations§
Source§impl<W: Write> BenEncoder<W>
impl<W: Write> BenEncoder<W>
Sourcepub fn new(writer: W, variant: BenVariant) -> Self
pub fn new(writer: W, variant: BenVariant) -> Self
Sourcepub fn write_json_value(&mut self, data: Value) -> Result<()>
pub fn write_json_value(&mut self, data: Value) -> Result<()>
Sourcepub fn finish(&mut self) -> Result<()>
pub fn finish(&mut self) -> Result<()>
Cleanup function to make sure the last sample is written to the BEN file if using the MkvChain variant.
This function is automatically called when the BenEncoder goes out of scope, but can be called manually if desired.
§Returns
A Result type that contains the result of the operation
§Errors
This function will return an error if the writer encounters an error while writing the last sample to the BEN file.
Trait Implementations§
Auto Trait Implementations§
impl<W> Freeze for BenEncoder<W>where
W: Freeze,
impl<W> RefUnwindSafe for BenEncoder<W>where
W: RefUnwindSafe,
impl<W> Send for BenEncoder<W>where
W: Send,
impl<W> Sync for BenEncoder<W>where
W: Sync,
impl<W> Unpin for BenEncoder<W>where
W: Unpin,
impl<W> UnwindSafe for BenEncoder<W>where
W: UnwindSafe,
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