mirror of
https://git.proxmox.com/git/proxmox
synced 2025-06-25 00:39:29 +00:00
macro: common defs: add default, and sort
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
bb673ec0db
commit
bb62dde9b0
@ -87,19 +87,21 @@ impl CommonTypeDefinition {
|
|||||||
|
|
||||||
#[derive(Builder)]
|
#[derive(Builder)]
|
||||||
pub struct ParameterDefinition {
|
pub struct ParameterDefinition {
|
||||||
|
#[builder(default)]
|
||||||
|
pub default: Option<syn::Expr>,
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
pub description: Option<syn::LitStr>,
|
pub description: Option<syn::LitStr>,
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
pub validate: Option<syn::Expr>,
|
pub maximum: Option<syn::Expr>,
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
pub minimum: Option<syn::Expr>,
|
pub minimum: Option<syn::Expr>,
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
pub maximum: Option<syn::Expr>,
|
pub validate: Option<syn::Expr>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ParameterDefinition {
|
impl ParameterDefinition {
|
||||||
pub fn builder() -> ParameterDefinitionBuilder {
|
pub fn builder() -> ParameterDefinitionBuilder {
|
||||||
ParameterDefinitionBuilder::default()
|
Default::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_object(obj: Object) -> Result<Self, Error> {
|
pub fn from_object(obj: Object) -> Result<Self, Error> {
|
||||||
@ -108,17 +110,20 @@ impl ParameterDefinition {
|
|||||||
let obj_span = obj.span();
|
let obj_span = obj.span();
|
||||||
for (key, value) in obj {
|
for (key, value) in obj {
|
||||||
match key.as_str() {
|
match key.as_str() {
|
||||||
|
"default" => {
|
||||||
|
def.default(Some(value.expect_expr()?));
|
||||||
|
}
|
||||||
"description" => {
|
"description" => {
|
||||||
def.description(Some(value.expect_lit_str()?));
|
def.description(Some(value.expect_lit_str()?));
|
||||||
}
|
}
|
||||||
"validate" => {
|
"maximum" => {
|
||||||
def.validate(Some(value.expect_expr()?));
|
def.maximum(Some(value.expect_expr()?));
|
||||||
}
|
}
|
||||||
"minimum" => {
|
"minimum" => {
|
||||||
def.minimum(Some(value.expect_expr()?));
|
def.minimum(Some(value.expect_expr()?));
|
||||||
}
|
}
|
||||||
"maximum" => {
|
"validate" => {
|
||||||
def.maximum(Some(value.expect_expr()?));
|
def.validate(Some(value.expect_expr()?));
|
||||||
}
|
}
|
||||||
other => c_bail!(key.span(), "invalid key in type definition: {}", other),
|
other => c_bail!(key.span(), "invalid key in type definition: {}", other),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user