|
9 | 9 |
|
10 | 10 | use std::collections::HashSet;
|
11 | 11 |
|
| 12 | +use bytesize::ByteSize; |
12 | 13 | use darling::{FromDeriveInput, FromField, FromMeta};
|
13 |
| -use parse_size::parse_size; |
14 | 14 | use proc_macro::TokenStream;
|
15 | 15 | use proc_macro2::Ident;
|
16 | 16 | use quote::quote;
|
@@ -103,7 +103,7 @@ struct ParsedField<'t> {
|
103 | 103 | /// # Field Limits
|
104 | 104 | ///
|
105 | 105 | /// You can use the `#[multipart(limit = "<size>")]` attribute to set field level limits. The limit
|
106 |
| -/// string is parsed using [parse_size]. |
| 106 | +/// string is parsed using [`bytesize`]. |
107 | 107 | ///
|
108 | 108 | /// Note: the form is also subject to the global limits configured using `MultipartFormConfig`.
|
109 | 109 | ///
|
@@ -150,7 +150,7 @@ struct ParsedField<'t> {
|
150 | 150 | /// struct Form { }
|
151 | 151 | /// ```
|
152 | 152 | ///
|
153 |
| -/// [parse_size]: https://docs.rs/parse-size/1/parse_size |
| 153 | +/// [`bytesize`]: https://docs.rs/bytesize/2 |
154 | 154 | #[proc_macro_derive(MultipartForm, attributes(multipart))]
|
155 | 155 | pub fn impl_multipart_form(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
156 | 156 | let input: syn::DeriveInput = parse_macro_input!(input);
|
@@ -191,8 +191,8 @@ pub fn impl_multipart_form(input: proc_macro::TokenStream) -> proc_macro::TokenS
|
191 | 191 | let attrs = FieldAttrs::from_field(field).map_err(|err| err.write_errors())?;
|
192 | 192 | let serialization_name = attrs.rename.unwrap_or_else(|| rust_name.to_string());
|
193 | 193 |
|
194 |
| - let limit = match attrs.limit.map(|limit| match parse_size(&limit) { |
195 |
| - Ok(size) => Ok(usize::try_from(size).unwrap()), |
| 194 | + let limit = match attrs.limit.map(|limit| match limit.parse::<ByteSize>() { |
| 195 | + Ok(ByteSize(size)) => Ok(usize::try_from(size).unwrap()), |
196 | 196 | Err(err) => Err(syn::Error::new(
|
197 | 197 | field.ident.as_ref().unwrap().span(),
|
198 | 198 | format!("Could not parse size limit `{}`: {}", limit, err),
|
|
0 commit comments