mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-05 04:26:30 +00:00
api-macro: reduce code output a little
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
881df81976
commit
03012deb3f
@ -607,7 +607,7 @@ fn create_wrapper_function(
|
|||||||
let #arg_name = input_map
|
let #arg_name = input_map
|
||||||
.remove(#name_str)
|
.remove(#name_str)
|
||||||
.map(::serde_json::from_value)
|
.map(::serde_json::from_value)
|
||||||
.transpose()?;
|
.transpose()?
|
||||||
});
|
});
|
||||||
if !optional {
|
if !optional {
|
||||||
// Non-optional types need to be extracted out of the option though:
|
// Non-optional types need to be extracted out of the option though:
|
||||||
@ -616,15 +616,13 @@ fn create_wrapper_function(
|
|||||||
// verifier already, so here we just use failure::bail! instead of building a
|
// verifier already, so here we just use failure::bail! instead of building a
|
||||||
// proper http error!
|
// proper http error!
|
||||||
body.extend(quote_spanned! { span =>
|
body.extend(quote_spanned! { span =>
|
||||||
let #arg_name = match #arg_name {
|
.ok_or_else(|| ::failure::format_err!(
|
||||||
Some(v) => v,
|
"missing non-optional parameter: {}",
|
||||||
None => ::failure::bail!(
|
#name_str,
|
||||||
"missing non-optional parameter: {}",
|
))?
|
||||||
#name_str,
|
|
||||||
),
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
body.extend(quote_spanned! { span => ; });
|
||||||
args.extend(quote_spanned! { span => #arg_name, });
|
args.extend(quote_spanned! { span => #arg_name, });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user