Skip to content

Return UploadPlan struct from upload_parameters#799

Open
demoray wants to merge 1 commit into
mainfrom
bcaswell/upload-plan-struct
Open

Return UploadPlan struct from upload_parameters#799
demoray wants to merge 1 commit into
mainfrom
bcaswell/upload-plan-struct

Conversation

@demoray
Copy link
Copy Markdown
Collaborator

@demoray demoray commented May 18, 2026

calc_concurrency and upload_parameters in src/upload/blobstore.rs
returned a positional (NonZeroU64, NonZeroUsize). Both values are
non-zero positive integers; nothing at the call site or in the tests
prevented a swapped destructure beyond the type difference, and that
protection disappears the first time anyone aligns the two on a
single integer type.

Introduce a private UploadPlan { block_size, concurrency } so the
single call site (BlobUploader::upload_file) reads field-named:

let plan = upload_parameters(file_size, self.block_size, self.concurrency)?;
BlobClientUploadOptions {
    parallel: Some(plan.concurrency),
    partition_size: Some(plan.block_size),
    ..Default::default()
}

Rewrite the five plan-returning tests to assert against a whole
UploadPlan literal instead of two positional bindings plus two

No behavior change. Public API unchanged — UploadPlan and
upload_parameters are both private.

Verified with:

  • cargo fmt --check
  • cargo clippy --all-features --all-targets -- -D warnings
  • cargo test --all-features

calc_concurrency and upload_parameters returned a positional
(NonZeroU64, NonZeroUsize). Both values are non-zero positive
integers; nothing at the call site or in the tests prevented a
swapped destructure beyond the type difference, and that protection
disappears the first time anyone aligns the two on a single integer
type.

Introduce a private UploadPlan { block_size, concurrency } so the
single call site reads field-named, and rewrite the five
plan-returning tests to assert against a whole UploadPlan literal
instead of two positional bindings plus two assert_eq! lines each.

The Error::TooLarge test is unchanged.

Verified with:

- cargo fmt --check
- cargo clippy --all-features --all-targets -- -D warnings
- cargo test --all-features
@demoray demoray enabled auto-merge (squash) May 18, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant