Struct object_store::WriteMultipart

source ·
pub struct WriteMultipart { /* private fields */ }
Expand description

A synchronous write API for uploading data in parallel in fixed size chunks

Uses multiple tokio tasks in a JoinSet to multiplex upload tasks in parallel

The design also takes inspiration from Sink with WriteMultipart::wait_for_capacity allowing back pressure on producers, prior to buffering the next part. However, unlike Sink this back pressure is optional, allowing integration with synchronous producers

Implementations§

source§

impl WriteMultipart

source

pub fn new(upload: Box<dyn MultipartUpload>) -> Self

Create a new WriteMultipart that will upload using 5MB chunks

source

pub fn new_with_chunk_size( upload: Box<dyn MultipartUpload>, chunk_size: usize ) -> Self

Create a new WriteMultipart that will upload in fixed chunk_size sized chunks

source

pub fn poll_for_capacity( &mut self, cx: &mut Context<'_>, max_concurrency: usize ) -> Poll<Result<()>>

Polls for there to be less than max_concurrency UploadPart in progress

See Self::wait_for_capacity for an async version of this function

source

pub async fn wait_for_capacity(&mut self, max_concurrency: usize) -> Result<()>

Wait until there are less than max_concurrency UploadPart in progress

See Self::poll_for_capacity for a Poll version of this function

source

pub fn write(&mut self, buf: &[u8])

Write data to this WriteMultipart

Data is buffered using PutPayloadMut::extend_from_slice. Implementations looking to write data from owned buffers may prefer Self::put as this avoids copying.

Note this method is synchronous (not async) and will immediately start new uploads as soon as the internal chunk_size is hit, regardless of how many outstanding uploads are already in progress.

Back pressure can optionally be applied to producers by calling Self::wait_for_capacity prior to calling this method

source

pub fn put(&mut self, bytes: Bytes)

Put a chunk of data into this WriteMultipart without copying

Data is buffered using PutPayloadMut::push. Implementations looking to perform writes from non-owned buffers should prefer Self::write as this will allow multiple calls to share the same underlying allocation.

See Self::write for information on backpressure

source

pub async fn abort(self) -> Result<()>

Abort this upload, attempting to clean up any successfully uploaded parts

source

pub async fn finish(self) -> Result<PutResult>

Flush final chunk, and await completion of all in-flight requests

Trait Implementations§

source§

impl Debug for WriteMultipart

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more