feat: implement FieldGroupReader for Option<Vec<T>> in multipart form… #3577
+39
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Type
Feature
PR Checklist
masterbranchrustfmtOverview
This PR adds support for using
Option<Vec<T>>with theMultipartFormextractor inactix-multipart. It enables multipart fields that may be completely absent or may appear multiple times, while preserving the distinction between missing fields and empty collections.Behavior
NoneSome(Vec<T>), where each occurrence is parsed viaT: FieldReader<'t>This allows optional repeated multipart fields to be represented ergonomically in
MultipartForm-derived structs.Example
tagsparts →tags == Nonetagsparts →tags == Some(vec![ ... ])Motivation
Issue #3576 identified a gap in multipart extraction:
Vec<T>could collect multiple values but did not distinguish absence from an empty list.Option<T>expressed absence but allowed only a single value.Supporting
Option<Vec<T>>resolves this by allowing both optionality and repetition.Implementation Details
Adds an implementation of
FieldGroupReader<'t>forOption<Vec<T>>inactix-multipart/src/form/mod.rs.handle_fieldcollects all occurrences of the field into a vector stored in extractor state.from_statereturns:Some(Vec<T>)if values were collected,Noneif the field never appeared.The change follows existing internal patterns and maintains full backward compatibility.
Changelog
To be added under the Unreleased section of
actix-multipart/CHANGES.md:Semver
This is a backward-compatible enhancement and should be released as a semver-minor update.
Related Issues