From cdf4326e4399f2331136f97b68bda2e94e52e4e8 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 4 Mar 2022 14:51:16 +0100 Subject: [PATCH] schema: factor out string verify fn and improve docs We'll need to name the type when we add more perl bindings. Signed-off-by: Wolfgang Bumiller --- proxmox-schema/src/schema.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/proxmox-schema/src/schema.rs b/proxmox-schema/src/schema.rs index 79b240f1..39aca451 100644 --- a/proxmox-schema/src/schema.rs +++ b/proxmox-schema/src/schema.rs @@ -1134,9 +1134,12 @@ pub enum ApiStringFormat { /// Use a schema to describe complex types encoded as string. PropertyString(&'static Schema), /// Use a verification function. - VerifyFn(fn(&str) -> Result<(), Error>), + VerifyFn(ApiStringVerifyFn), } +/// Type of a verification function for [`StringSchema`]s. +pub type ApiStringVerifyFn = fn(&str) -> Result<(), Error>; + impl ApiStringFormat { /// Gets the underlying [`&[EnumEntry]`](EnumEntry) list, panics on different formats. pub const fn unwrap_enum_format(&self) -> &'static [EnumEntry] { @@ -1457,6 +1460,7 @@ impl UpdaterType for Vec { type Updater = Option; } +/// Trait signifying that a type contains an API schema. pub trait ApiType { const API_SCHEMA: Schema; } @@ -1490,6 +1494,7 @@ impl Updater for Option { } } +/// Return type schema. Return types may be any schema and additionally be optional. #[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))] pub struct ReturnType { /// A return type may be optional, meaning the method may return null or some fixed data.