diff --git a/proxmox/src/api/router.rs b/proxmox/src/api/router.rs index e18c2474..cd3bbbed 100644 --- a/proxmox/src/api/router.rs +++ b/proxmox/src/api/router.rs @@ -10,11 +10,14 @@ use hyper::Body; use percent_encoding::percent_decode_str; use serde_json::Value; -use crate::api::schema::{self, ObjectSchema, ParameterSchema, Schema}; +use crate::api::schema::{ObjectSchema, ParameterSchema, Schema}; use crate::api::RpcEnvironment; use super::Permission; +/// Deprecated reexport: +pub use super::schema::ReturnType; + /// A synchronous API handler gets a json Value as input and returns a json Value as output. /// /// Most API handler are synchronous. Use this to define such handler: @@ -398,33 +401,6 @@ pub struct ApiAccess { pub permission: &'static Permission, } -#[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. - /// - /// If true, the return type in pseudo openapi terms would be `"oneOf": [ "null", "T" ]`. - pub optional: bool, - - /// The method's return type. - pub schema: &'static schema::Schema, -} - -impl std::fmt::Debug for ReturnType { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - if self.optional { - write!(f, "optional {:?}", self.schema) - } else { - write!(f, "{:?}", self.schema) - } - } -} - -impl ReturnType { - pub const fn new(optional: bool, schema: &'static Schema) -> Self { - Self { optional, schema } - } -} - /// This struct defines a synchronous API call which returns the result as json `Value` #[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))] pub struct ApiMethod { diff --git a/proxmox/src/api/schema.rs b/proxmox/src/api/schema.rs index e3ee7a31..8bdc64da 100644 --- a/proxmox/src/api/schema.rs +++ b/proxmox/src/api/schema.rs @@ -1587,3 +1587,30 @@ impl Updater for Option { self.is_none() } } + +#[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. + /// + /// If true, the return type in pseudo openapi terms would be `"oneOf": [ "null", "T" ]`. + pub optional: bool, + + /// The method's return type. + pub schema: &'static Schema, +} + +impl std::fmt::Debug for ReturnType { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.optional { + write!(f, "optional {:?}", self.schema) + } else { + write!(f, "{:?}", self.schema) + } + } +} + +impl ReturnType { + pub const fn new(optional: bool, schema: &'static Schema) -> Self { + Self { optional, schema } + } +}