PartEncoder

Trait PartEncoder 

Source
pub trait PartEncoder<Item> {
    type Error: EncodeError;

    // Required methods
    fn restore(&self) -> Result<Self, Self::Error>
       where Self: Sized;
    fn encode(&mut self, item: Item) -> Result<usize, Self::Error>;
    fn flush(&mut self) -> Result<(), Self::Error>;
    fn into_body(self) -> Result<PartBody, Self::Error>;

    // Provided method
    fn clear(&self) -> Result<Self, Self::Error>
       where Self: Sized { ... }
}
Expand description

Encoding for items in a part of a multipart upload.

Required Associated Types§

Source

type Error: EncodeError

The type of value returned when encoding items is not successful.

Required Methods§

Source

fn restore(&self) -> Result<Self, Self::Error>
where Self: Sized,

Restore this encoder’s state for a new upload.

Source

fn encode(&mut self, item: Item) -> Result<usize, Self::Error>

Encode this item in the part, returning the number of bytes written.

Source

fn flush(&mut self) -> Result<(), Self::Error>

Flush the items in any internal buffer.

Source

fn into_body(self) -> Result<PartBody, Self::Error>

Convert the encoder to a PartBody.

Provided Methods§

Source

fn clear(&self) -> Result<Self, Self::Error>
where Self: Sized,

Clear the encoder to prepare for a new part.

Override this method to provide an alternative means of building the encoder in between uploads if, for example if preparing for a new part is different than preparing for a new upload.

Implementors§

Source§

impl<Item: AsRef<str>> PartEncoder<Item> for LinesEncoder

Source§

impl<Item: Serialize> PartEncoder<Item> for CsvEncoder

Available on crate feature csv only.
Source§

impl<Item: Serialize> PartEncoder<Item> for JsonLinesEncoder

Source§

impl<T: AsRef<[u8]>> PartEncoder<T> for PartBody