Skip to content

Conversation

adam-fowler
Copy link
Contributor

Use associatedtype Body in initialiser for MultipartPartDecodable. This also required setting this as the primary associated type so we can cast to it in FormDataDecoder. This required tests to also be updated so the same buffer type was used in the File type and the test decodeSimilVaporFileType that used it.

Use associatedtype Body in initialiser for MultipartPartDecodable

Copy link
Member

@ptoffy ptoffy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly I originally went with some MultipartPartBodyElement instead of Body in the init to allow different types to be used in the encoder and decoder when conforming to MultipartPartConvertible. This breaks that. The associated type was probably left as an oversight

@adam-fowler
Copy link
Contributor Author

adam-fowler commented Sep 23, 2025

If I remember correctly I originally went with some MultipartPartBodyElement instead of Body in the init to allow different types to be used in the encoder and decoder when conforming to MultipartPartConvertible. This breaks that. The associated type was probably left as an oversight

The problem is you get a generic body and all you can use are RangeReplaceableCollection methods which means you inevitable end up copying the buffer, when in many cases you shouldn't need to. If you enforce the body buffer type then the user can make an informed decision on whether they want to copy the buffer.

In what situation would you use different buffer types in the one type?

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.

2 participants