aws-s3-transfer 1.0.0

Transfer Manager for Amazon S3 - a high-performance data plane client for uploading and downloading objects and directories.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

//! Pooled mutable storage for upload parts.

use std::future::Future;
use std::io;
use std::pin::Pin;
use std::ptr::NonNull;
use std::task::{Context, Poll};

use bytes::buf::UninitSlice;
use bytes::BufMut;

use crate::memory::{BufferPool, SegmentedBytes};
use crate::runtime::buffer_pool::{PooledBufMut, Reservation, ReserveFuture};

/// Mutable pooled storage for one upload part.
///
/// [`PartBuffer::new`] creates an empty buffer charged to a [`BufferPool`]. Creating it admits no
/// memory. Call [`PartBuffer::poll_acquire`] before writing, retain the buffer across
/// [`Poll::Pending`], copy bytes in with [`PartBuffer::fill_from_slice`], and call
/// [`PartBuffer::freeze`] when the part is complete.
///
/// Each acquisition request admits one memory envelope. [`PartBuffer::writable`] exposes only bytes
/// inside that envelope. When an envelope is full, the next call to `poll_acquire` keeps its bytes
/// without copying and admits the requested next envelope.
///
/// The common path requests the part length once and fills the complete part through repeated
/// polls. Smaller envelopes suit externally paced producers, but completed envelopes remain charged
/// to the pool until the returned [`SegmentedBytes`] is released.
#[derive(Debug)]
pub struct PartBuffer {
    pool: BufferPool,
    max_len: usize,
    completed: SegmentedBytes,
    state: PartBufferState,
}

// SAFETY: pooled mutable authority is reachable only through methods requiring `&mut self`.
// Shared methods inspect lengths and immutable completed bytes; they neither expose nor mutate the
// exclusive ranges held by `PooledBufMut`.
unsafe impl Sync for PartBuffer {}

/// Admission and mutable ownership for the current logical envelope.
#[derive(Debug)]
enum PartBufferState {
    /// No reservation request or mutable buffer is active.
    Empty,
    /// The first poll latched `envelope` and entered pool admission.
    Reserving {
        envelope_remaining: usize,
        future: ReserveFuture,
    },
    /// One granted envelope owns mutable pooled storage.
    Writable {
        envelope_remaining: usize,
        reservation: Option<Reservation>,
        buffer: PooledBufMut,
    },
}

impl PartBuffer {
    /// Creates an empty buffer for one part of at most `max_len` bytes, charged to `pool`.
    ///
    /// Creating a buffer admits no memory; [`Self::poll_acquire`] does. The buffer is not tied to
    /// a client or a transfer. Share `pool` with a client through
    /// [`MemoryConfig::Explicit`](crate::config::MemoryConfig::Explicit) to bound their memory
    /// use together.
    ///
    /// # Panics
    ///
    /// Panics if `max_len` is zero.
    pub fn new(pool: &BufferPool, max_len: usize) -> Self {
        assert!(max_len != 0, "part buffer length must be nonzero");
        Self {
            pool: pool.clone(),
            max_len,
            completed: SegmentedBytes::from(bytes::Bytes::new()),
            state: PartBufferState::Empty,
        }
    }

    /// Polls until [`Self::writable`] is nonzero, admitting up to `envelope` bytes when a new
    /// envelope is needed.
    ///
    /// The first `envelope` value is retained while admission is pending. Calls made while the
    /// current envelope still has writable bytes return immediately; their `envelope` argument
    /// applies only after the current envelope becomes full. Bytes written into a full envelope
    /// are kept before the next envelope is admitted. [`Self::writable`] may be smaller than the
    /// envelope's unwritten bytes; poll again once it reaches zero.
    ///
    /// Returns `Poll::Pending` until the pool admits the envelope; the waker of `cx` is notified
    /// when admission may progress. Dropping the buffer while admission is pending cancels the
    /// request.
    ///
    /// # Errors
    ///
    /// - [`io::ErrorKind::InvalidInput`] when a new envelope is needed and `envelope` is outside
    ///   `1..=`[`Self::remaining`]. The request does not enter admission.
    /// - [`io::ErrorKind::Other`] when the pool cannot admit or provide the envelope, including an
    ///   envelope larger than the pool's capacity. The error's source describes the failure; its
    ///   type is not public.
    pub fn poll_acquire(&mut self, cx: &mut Context<'_>, envelope: usize) -> Poll<io::Result<()>> {
        loop {
            match &mut self.state {
                PartBufferState::Writable {
                    envelope_remaining,
                    buffer,
                    ..
                } if *envelope_remaining != 0 && buffer.remaining_mut() != 0 => {
                    return Poll::Ready(Ok(()));
                }
                PartBufferState::Writable {
                    envelope_remaining, ..
                } => {
                    let continuation = *envelope_remaining;
                    let tail = self.publish_current();
                    if continuation == 0 {
                        let remaining = self.remaining();
                        if envelope == 0 || envelope > remaining {
                            return Poll::Ready(Err(invalid_envelope(envelope, remaining)));
                        }
                        if let Some(buffer) = tail {
                            self.state = PartBufferState::Writable {
                                envelope_remaining: envelope,
                                reservation: None,
                                buffer,
                            };
                            return Poll::Ready(Ok(()));
                        }
                        self.start_reservation(envelope);
                    } else {
                        if tail.is_some() {
                            panic!("exhausted part-buffer storage retained writable capacity");
                        }
                        self.start_reservation(continuation);
                    }
                }
                PartBufferState::Empty => {
                    let remaining = self.remaining();
                    if envelope == 0 || envelope > remaining {
                        return Poll::Ready(Err(invalid_envelope(envelope, remaining)));
                    }
                    self.start_reservation(envelope);
                }
                PartBufferState::Reserving {
                    envelope_remaining,
                    future,
                } => {
                    let reservation = match Pin::new(future).poll(cx) {
                        Poll::Pending => return Poll::Pending,
                        Poll::Ready(Ok(reservation)) => reservation,
                        Poll::Ready(Err(error)) => {
                            self.state = PartBufferState::Empty;
                            return Poll::Ready(Err(io::Error::other(error)));
                        }
                    };
                    let envelope_remaining = *envelope_remaining;
                    match self.pool.acquire(&reservation, envelope_remaining) {
                        Ok(buffer) => {
                            self.state = PartBufferState::Writable {
                                envelope_remaining,
                                reservation: Some(reservation),
                                buffer,
                            };
                            return Poll::Ready(Ok(()));
                        }
                        Err(error) => {
                            self.state = PartBufferState::Empty;
                            return Poll::Ready(Err(io::Error::other(error)));
                        }
                    }
                }
            }
        }
    }

    /// Returns initialized bytes accumulated for this part.
    pub fn len(&self) -> usize {
        self.completed
            .len()
            .checked_add(self.current_len())
            .expect("part buffer length overflowed")
    }

    /// Returns whether no bytes have been written.
    pub fn is_empty(&self) -> bool {
        self.len() == 0
    }

    /// Returns bytes that can still be written before this part reaches its maximum length.
    ///
    /// This differs from [`Self::writable`], which counts only bytes inside the currently admitted
    /// envelope.
    pub fn remaining(&self) -> usize {
        self.max_len
            .checked_sub(self.len())
            .expect("part buffer length exceeded its limit")
    }

    /// Returns bytes that can be written into the admitted envelope without another
    /// [`Self::poll_acquire`].
    ///
    /// Zero before the first acquisition, while admission is pending, and once the envelope is
    /// full. Never exceeds [`Self::remaining`].
    pub fn writable(&self) -> usize {
        match &self.state {
            PartBufferState::Writable {
                envelope_remaining,
                buffer,
                ..
            } => (*envelope_remaining).min(buffer.remaining_mut()),
            PartBufferState::Empty | PartBufferState::Reserving { .. } => 0,
        }
    }

    /// Copies the first `min(src.len(), self.writable())` bytes of `src` and returns that count.
    ///
    /// Returns zero when [`Self::writable`] is zero; poll [`Self::poll_acquire`] to admit more.
    pub fn fill_from_slice(&mut self, src: &[u8]) -> usize {
        let mut copied = 0;
        while copied < src.len() {
            let chunk = self.chunk_mut();
            let count = chunk.len().min(src.len() - copied);
            if count == 0 {
                break;
            }
            chunk[..count].copy_from_slice(&src[copied..copied + count]);
            // SAFETY: the first `count` bytes of the chunk were initialized by the copy above.
            unsafe {
                self.advance_mut(count);
            }
            copied += count;
        }
        copied
    }

    /// Publishes all initialized bytes and ends pending or active admission.
    ///
    /// Pending admission is cancelled. The initialized bytes of a partially filled envelope are
    /// kept without copying, and pooled memory that holds none of them is released.
    pub fn freeze(mut self) -> SegmentedBytes {
        if matches!(self.state, PartBufferState::Writable { .. }) {
            self.freeze_current();
        }
        self.completed
    }

    /// Returns initialized bytes in the active mutable buffer.
    fn current_len(&self) -> usize {
        match &self.state {
            PartBufferState::Writable { buffer, .. } => buffer.len(),
            PartBufferState::Empty | PartBufferState::Reserving { .. } => 0,
        }
    }

    /// Starts admission for storage not already covered by a retained tail.
    fn start_reservation(&mut self, envelope_remaining: usize) {
        self.state = PartBufferState::Reserving {
            envelope_remaining,
            future: self.pool.reserve(envelope_remaining),
        };
    }

    /// Publishes initialized prefixes while retaining any writable carrier tail.
    fn publish_current(&mut self) -> Option<PooledBufMut> {
        let state = std::mem::replace(&mut self.state, PartBufferState::Empty);
        let PartBufferState::Writable {
            reservation,
            mut buffer,
            ..
        } = state
        else {
            panic!("part buffer has no writable envelope to publish");
        };
        while !buffer.is_empty() {
            let count = buffer.initialized_chunk().len();
            let published = buffer.publish_prefix(count);
            self.completed.append_pool_view(&self.pool, published);
        }
        if let Some(reservation) = reservation {
            reservation.close_acquisition();
        }
        (buffer.remaining_mut() != 0).then_some(buffer)
    }

    /// Freezes the active mutable buffer when no later write needs its tail.
    fn freeze_current(&mut self) {
        let state = std::mem::replace(&mut self.state, PartBufferState::Empty);
        let PartBufferState::Writable {
            reservation,
            buffer,
            ..
        } = state
        else {
            panic!("part buffer has no writable envelope to freeze");
        };
        if let Some(reservation) = reservation {
            reservation.close_acquisition();
        }
        self.completed.append(buffer.freeze());
    }
}

impl PartBuffer {
    /// Returns the next uninitialized run inside the admitted envelope.
    ///
    /// The run is empty when [`Self::writable`] is zero. A nonempty run may be shorter than
    /// `writable()` when the envelope spans several pooled runs.
    pub(crate) fn chunk_mut(&mut self) -> &mut UninitSlice {
        let PartBufferState::Writable {
            envelope_remaining,
            buffer,
            ..
        } = &mut self.state
        else {
            // SAFETY: a dangling pointer is valid for a zero-length slice, and the returned borrow
            // remains tied to `self`.
            return unsafe {
                UninitSlice::from_raw_parts_mut(NonNull::<u8>::dangling().as_ptr(), 0)
            };
        };
        let chunk = buffer.chunk_mut();
        let exposed = chunk.len().min(*envelope_remaining);
        &mut chunk[..exposed]
    }

    /// Marks the first `count` bytes of [`Self::chunk_mut`] as written.
    ///
    /// # Panics
    ///
    /// Panics if `count` exceeds [`Self::writable`].
    ///
    /// # Safety
    ///
    /// The caller must have initialized the first `count` bytes of the run most recently returned
    /// by [`Self::chunk_mut`], with no intervening mutation of `self`.
    pub(crate) unsafe fn advance_mut(&mut self, count: usize) {
        assert!(
            count <= self.writable(),
            "advanced beyond the current part-buffer envelope"
        );
        let PartBufferState::Writable {
            envelope_remaining,
            buffer,
            ..
        } = &mut self.state
        else {
            assert_eq!(count, 0, "advanced a part buffer without writable storage");
            return;
        };
        // SAFETY: the caller initialized `count` bytes from the range returned by `chunk_mut`, and
        // the assertion above keeps the update inside both the pooled range and logical envelope.
        unsafe {
            buffer.advance_mut(count);
        }
        *envelope_remaining = envelope_remaining
            .checked_sub(count)
            .expect("advanced beyond the current part-buffer envelope");
    }
}

/// Constructs an invalid-input error for an envelope outside the remaining part.
fn invalid_envelope(envelope: usize, remaining: usize) -> io::Error {
    io::Error::new(
        io::ErrorKind::InvalidInput,
        format!("part buffer envelope must be between 1 and {remaining} bytes, got {envelope}"),
    )
}

#[cfg(test)]
mod tests {
    use crate::types::ByteSize;
    use std::task::Waker;

    use bytes::Buf;

    use super::*;
    use crate::config::MemoryBudgetConfig;

    const TEST_POOL_CAPACITY: usize = 1024 * 1024;

    fn test_pool() -> BufferPool {
        BufferPool::builder()
            .memory_budget(MemoryBudgetConfig::Limit(ByteSize::new(
                TEST_POOL_CAPACITY as u64,
            )))
            .build()
            .unwrap()
    }

    fn poll_acquire(buffer: &mut PartBuffer, envelope: usize) -> Poll<io::Result<()>> {
        let waker = Waker::noop();
        let mut cx = Context::from_waker(waker);
        buffer.poll_acquire(&mut cx, envelope)
    }

    #[test]
    fn complete_envelope_freezes_without_copying() {
        let pool = test_pool();
        let carrier_size = pool.carrier_size();
        let mut buffer = PartBuffer::new(&pool, carrier_size);

        assert!(poll_acquire(&mut buffer, carrier_size).is_ready());
        let ptr = buffer.chunk_mut().as_mut_ptr();
        let data = b"payload";
        assert_eq!(buffer.fill_from_slice(data), data.len());
        assert_eq!(buffer.len(), data.len());
        assert_eq!(buffer.remaining(), carrier_size - data.len());

        let frozen = buffer.freeze();
        assert_eq!(frozen.chunk().as_ptr(), ptr.cast());
        assert_eq!(frozen.chunk(), data);
        assert_eq!(pool.metrics().in_use_bytes(), carrier_size as u64);
        drop(frozen);
        assert_eq!(pool.metrics().in_use_bytes(), 0);
    }

    #[test]
    fn full_envelopes_roll_over_without_losing_carrier_tails() {
        let pool = test_pool();
        let first = b"abc";
        let second = b"defg";
        let expected = [&first[..], &second[..]].concat();
        let mut buffer = PartBuffer::new(&pool, expected.len());

        assert!(poll_acquire(&mut buffer, first.len()).is_ready());
        assert_eq!(buffer.fill_from_slice(first), first.len());
        assert_eq!(buffer.writable(), 0);

        assert!(poll_acquire(&mut buffer, second.len()).is_ready());
        assert_eq!(buffer.fill_from_slice(second), second.len());
        assert_eq!(buffer.len(), expected.len());
        assert_eq!(pool.metrics().in_use_bytes(), pool.carrier_size() as u64);

        let frozen = buffer.freeze();
        let segments = frozen.into_segments();
        assert_eq!(segments.len(), 1);
        assert_eq!(segments[0], expected);
        drop(segments);
        assert_eq!(pool.metrics().in_use_bytes(), 0);
    }

    #[test]
    fn envelope_continues_after_exhausting_a_reused_tail() {
        let pool = test_pool();
        let carrier_size = pool.carrier_size();
        let mut buffer = PartBuffer::new(&pool, carrier_size + 3);
        let mut expected = Vec::with_capacity(carrier_size + 3);

        let head = b"abc";
        assert!(poll_acquire(&mut buffer, 3).is_ready());
        assert_eq!(buffer.fill_from_slice(head), head.len());
        expected.extend_from_slice(head);

        assert!(poll_acquire(&mut buffer, carrier_size).is_ready());
        let tail_len = buffer.writable();
        let tail = vec![b'x'; tail_len];
        assert_eq!(buffer.fill_from_slice(&tail), tail.len());
        expected.extend_from_slice(&tail);
        assert_eq!(buffer.writable(), 0);

        assert!(poll_acquire(&mut buffer, 1).is_ready());
        assert_eq!(buffer.writable(), 3);
        let end = b"end";
        assert_eq!(buffer.fill_from_slice(end), end.len());
        expected.extend_from_slice(end);

        assert_eq!(buffer.freeze().into_contiguous(), expected);
        assert_eq!(pool.metrics().in_use_bytes(), 0);
    }

    #[test]
    fn partial_envelope_remains_active_across_acquire_polls() {
        let pool = test_pool();
        let mut buffer = PartBuffer::new(&pool, 8);

        let first = b"abc";
        let rest = b"defgh";
        assert!(poll_acquire(&mut buffer, 8).is_ready());
        assert_eq!(buffer.fill_from_slice(first), first.len());
        assert!(poll_acquire(&mut buffer, 2).is_ready());
        assert_eq!(buffer.writable(), 5);
        assert_eq!(buffer.fill_from_slice(rest), rest.len());

        assert_eq!(
            buffer.freeze().into_contiguous(),
            [&first[..], &rest[..]].concat()
        );
    }

    #[test]
    fn pending_reservation_is_retained_and_cancelled_on_drop() {
        let pool = test_pool();
        let carrier_size = pool.carrier_size();
        let holder = pool.try_reserve(TEST_POOL_CAPACITY).unwrap().unwrap();
        let held = pool.acquire(&holder, TEST_POOL_CAPACITY).unwrap();
        let mut buffer = PartBuffer::new(&pool, carrier_size);

        assert!(poll_acquire(&mut buffer, carrier_size).is_pending());
        assert_eq!(pool.metrics().waiting_requests(), 1);
        drop(buffer);
        assert_eq!(pool.metrics().waiting_requests(), 0);

        drop(held);
        holder.close_acquisition();
    }

    #[test]
    fn pending_reservation_latches_its_first_envelope() {
        let pool = test_pool();
        let carrier_size = pool.carrier_size();
        let holder = pool.try_reserve(TEST_POOL_CAPACITY).unwrap().unwrap();
        let held = pool.acquire(&holder, TEST_POOL_CAPACITY).unwrap();
        let mut buffer = PartBuffer::new(&pool, carrier_size);

        assert!(poll_acquire(&mut buffer, 3).is_pending());
        assert!(poll_acquire(&mut buffer, 7).is_pending());

        drop(held);
        holder.close_acquisition();

        assert!(poll_acquire(&mut buffer, 7).is_ready());
        assert_eq!(buffer.writable(), 3);
    }

    #[test]
    fn invalid_envelope_does_not_enter_admission() {
        let pool = test_pool();
        let mut buffer = PartBuffer::new(&pool, 8);

        let Poll::Ready(result) = poll_acquire(&mut buffer, 9) else {
            panic!("invalid envelope entered admission");
        };
        let error = result.unwrap_err();

        assert_eq!(error.kind(), io::ErrorKind::InvalidInput);
        assert_eq!(pool.metrics().waits_total(), 0);
    }

    /// A source longer than the admitted envelope is copied only up to the envelope, and the
    /// count reports the copied prefix. The first envelope spans three carriers, so one call must
    /// copy across several writable runs; the second is served from the third carrier's tail.
    #[test]
    fn fill_from_slice_copies_up_to_the_envelope_and_returns_the_count() {
        let pool = test_pool();
        let carrier_size = pool.carrier_size();
        let first = 2 * carrier_size + 1;
        let max_len = first + 3;
        let mut buffer = PartBuffer::new(&pool, max_len);
        let source: Vec<u8> = (0..max_len + 5).map(|i| i as u8).collect();

        assert!(poll_acquire(&mut buffer, first).is_ready());
        assert_eq!(buffer.writable(), first);
        assert_eq!(buffer.fill_from_slice(&source), first);
        assert_eq!(buffer.len(), first);
        assert_eq!(buffer.writable(), 0);
        assert_eq!(buffer.fill_from_slice(&source[first..]), 0);
        assert_eq!(buffer.len(), first);

        assert!(poll_acquire(&mut buffer, 3).is_ready());
        assert_eq!(buffer.writable(), 3);
        assert_eq!(buffer.fill_from_slice(&source[first..]), 3);
        assert_eq!(buffer.remaining(), 0);
        assert_eq!(buffer.writable(), 0);

        assert_eq!(buffer.freeze().into_contiguous(), source[..max_len]);
        assert_eq!(pool.metrics().in_use_bytes(), 0);
    }

    /// `writable` counts only admitted bytes: none before the first acquisition or while it is
    /// pending, and none once the envelope is full, even when the part has room left.
    #[test]
    fn writable_is_zero_before_acquire_and_when_full() {
        let pool = test_pool();
        let holder = pool.try_reserve(TEST_POOL_CAPACITY).unwrap().unwrap();
        let mut buffer = PartBuffer::new(&pool, 8);

        assert_eq!(buffer.writable(), 0);
        assert_eq!(buffer.fill_from_slice(b"abc"), 0);
        assert!(buffer.is_empty());

        assert!(poll_acquire(&mut buffer, 4).is_pending());
        assert_eq!(buffer.writable(), 0);
        assert_eq!(buffer.fill_from_slice(b"abc"), 0);

        holder.close_acquisition();
        assert!(poll_acquire(&mut buffer, 4).is_ready());
        assert_eq!(buffer.writable(), 4);
        let data = b"abcd";
        assert_eq!(buffer.fill_from_slice(data), data.len());
        assert_eq!(buffer.writable(), 0);
        assert_eq!(buffer.remaining(), 4);
        assert_eq!(buffer.fill_from_slice(b"e"), 0);

        assert_eq!(buffer.freeze().into_contiguous(), data[..]);
    }

    #[test]
    fn part_buffer_is_send_and_sync() {
        fn assert_send_sync<T: Send + Sync>() {}
        assert_send_sync::<PartBuffer>();
    }
}

#[cfg(all(test, not(s3_tm_loom)))]
mod prop_tests;