magiclen / rocket-multipart-form-data

This crate provides a multipart parser for the Rocket framework.
MIT License
35 stars 14 forks source link

Fixed or infinite repetition support #6

Closed arnodb closed 4 years ago

arnodb commented 4 years ago

Hi,

I've been playing with this multipart crate and wanted to have "infinite" repetition support. Unfortunately the current design forces "fixed" repetition. Moreover the current repetition support has issues among which the need to repeat all the field acceptance criteria (e.g. content type).

In this issue I propose to modify the API to take an repetition: Repetition in field options where Repetition is defined like this:

enum Repetition {
    Fixed(usize),
    Infinite,
}

It shall default to Fixed(1) when calling MultipartFormDataField helpers.

More generally I don't think we need anything like an optional lower boundary and an optional upper boundary.

Another consideration: it may be a good idea to forbid duplicated fields to avoid the mess of computing an actual repetition value for a given field.

What do you think?

-- Arnaud

magiclen commented 4 years ago

Good idea. And it has been implemented since 0.8.0.