pub struct FileEncoder {
    buf: Box<[MaybeUninit<u8>]>,
    buffered: usize,
    flushed: usize,
    file: File,
    res: Result<(), Error>,
}
Expand description

FileEncoder encodes data to file via fixed-size buffer.

When encoding large amounts of data to a file, using FileEncoder may be preferred over using MemEncoder to encode to a Vec, and then writing the Vec to file, as the latter uses as much memory as there is encoded data, while the former uses the fixed amount of memory allocated to the buffer. FileEncoder also has the advantage of not needing to reallocate as data is appended to it, but the disadvantage of requiring more error handling, which has some runtime overhead.

Fields§

§buf: Box<[MaybeUninit<u8>]>

The input buffer. For adequate performance, we need more control over buffering than BufWriter offers. If BufWriter ever offers a raw buffer access API, we can use it, and remove buf and buffered.

§buffered: usize§flushed: usize§file: File§res: Result<(), Error>

Implementations§

Trait Implementations§

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 48 bytes