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
impl WriteMultipart
sourcepub fn new(upload: Box<dyn MultipartUpload>) -> Self
pub fn new(upload: Box<dyn MultipartUpload>) -> Self
Create a new WriteMultipart
that will upload using 5MB chunks
sourcepub fn new_with_chunk_size(
upload: Box<dyn MultipartUpload>,
chunk_size: usize,
) -> Self
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
sourcepub fn poll_for_capacity(
&mut self,
cx: &mut Context<'_>,
max_concurrency: usize,
) -> Poll<Result<()>>
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
sourcepub async fn wait_for_capacity(&mut self, max_concurrency: usize) -> Result<()>
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
sourcepub fn write(&mut self, buf: &[u8])
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
sourcepub fn put(&mut self, bytes: Bytes)
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
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WriteMultipart
impl !RefUnwindSafe for WriteMultipart
impl Send for WriteMultipart
impl !Sync for WriteMultipart
impl Unpin for WriteMultipart
impl !UnwindSafe for WriteMultipart
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more