mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-09 17:41:05 +00:00
api: make ApiMethodInfo already require Send + Sync
ApiMethodInfo provides static information about a type Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
eb4e28d7bf
commit
617e25abba
@ -347,7 +347,7 @@ pub fn handle_function(
|
|||||||
#struct_name::wrapped_api_handler(params)
|
#struct_name::wrapped_api_handler(params)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn method_info(&self) -> &(dyn ::proxmox::api::ApiMethodInfo + Send + Sync) {
|
fn method_info(&self) -> &dyn ::proxmox::api::ApiMethodInfo {
|
||||||
self as _
|
self as _
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ use serde_json::{json, Value};
|
|||||||
/// Method entries in a `Router` are actually just `&dyn ApiMethodInfo` trait objects.
|
/// Method entries in a `Router` are actually just `&dyn ApiMethodInfo` trait objects.
|
||||||
/// This contains all the info required to call, document, or command-line-complete parameters for
|
/// This contains all the info required to call, document, or command-line-complete parameters for
|
||||||
/// a method.
|
/// a method.
|
||||||
pub trait ApiMethodInfo {
|
pub trait ApiMethodInfo: Send + Sync {
|
||||||
fn description(&self) -> &'static str;
|
fn description(&self) -> &'static str;
|
||||||
fn parameters(&self) -> &'static [Parameter];
|
fn parameters(&self) -> &'static [Parameter];
|
||||||
fn return_type(&self) -> &'static TypeInfo;
|
fn return_type(&self) -> &'static TypeInfo;
|
||||||
@ -17,11 +17,11 @@ pub trait ApiMethodInfo {
|
|||||||
fn reload_timezone(&self) -> bool;
|
fn reload_timezone(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ApiHandler: ApiMethodInfo + Send + Sync {
|
pub trait ApiHandler: ApiMethodInfo {
|
||||||
type Body;
|
type Body;
|
||||||
|
|
||||||
fn call(&self, params: Value) -> super::ApiFuture<Self::Body>;
|
fn call(&self, params: Value) -> super::ApiFuture<Self::Body>;
|
||||||
fn method_info(&self) -> &(dyn ApiMethodInfo + Send + Sync);
|
fn method_info(&self) -> &dyn ApiMethodInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Body: 'static> dyn ApiHandler<Body = Body> {
|
impl<Body: 'static> dyn ApiHandler<Body = Body> {
|
||||||
@ -133,12 +133,12 @@ impl<Body> ApiHandler for ApiMethod<Body> {
|
|||||||
(self.handler)(params)
|
(self.handler)(params)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn method_info(&self) -> &(dyn ApiMethodInfo + Send + Sync) {
|
fn method_info(&self) -> &dyn ApiMethodInfo {
|
||||||
self as _
|
self as _
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl dyn ApiMethodInfo + Send + Sync {
|
impl dyn ApiMethodInfo {
|
||||||
pub fn api_dump(&self) -> Value {
|
pub fn api_dump(&self) -> Value {
|
||||||
let parameters = Value::Object(std::iter::FromIterator::from_iter(
|
let parameters = Value::Object(std::iter::FromIterator::from_iter(
|
||||||
self.parameters()
|
self.parameters()
|
||||||
|
Loading…
Reference in New Issue
Block a user