You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Linux asus 5.18.12-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 15 Jul 2022 15:33:02 +0000 x86_64 GNU/Linux
Description
axum::extract::multipart::Field should implement Clone its really hard to if a field.name() equals to what we are looking for because it can't be cloned, all getter methods are self not &self. Implementing Clone will make it easy or else its really hard.
fncreate_post(mutform:Multipart) -> Result<Json<String>,ApiError>{whileletSome(field) = form.next_field().await.unwrap(){// &self - no problemmatch field.name(){// Did call field.text() which is &self"foo" => {..}
...
_ => ()}// Checking if the content_type is image or video and then processes it.// Error here because field was deleted by text() methodmatch field.content_type(){ ...}}}
The text was updated successfully, but these errors were encountered:
Field cannot be Clone because it contains a &mut Multipart. That is required to uphold an invariant.
Think of Field as a "pointer into a the request body stream" meaning it doesn't make sense to clone since you cannot consume a stream twice. That is why the Field::text takes self and is async.
Seems to me that putting a continue in your loop should fix your problem.
Bug Report
Version
0.5.5
├── axum v0.5.5
│ ├── axum-core v0.2.4
│ ├── axum-core v0.2.4 (*)
Platform
Linux asus 5.18.12-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 15 Jul 2022 15:33:02 +0000 x86_64 GNU/Linux
Description
axum::extract::multipart::Field
should implementClone
its really hard to if afield.name()
equals to what we are looking for because it can't be cloned, all getter methods areself
not&self
. ImplementingClone
will make it easy or else its really hard.The text was updated successfully, but these errors were encountered: