]> git.proxmox.com Git - proxmox-backup.git/blobdiff - src/api/router.rs
api: pass RpcEnvirnment to api handlers
[proxmox-backup.git] / src / api / router.rs
index a70b56eefdaf5c19a837f0c5025636040af7b227..d19ced5981de6e2d7d5ef9da2f4e0966440aa5af 100644 (file)
@@ -11,7 +11,14 @@ use hyper::http::request::Parts;
 
 pub type BoxFut = Box<Future<Item = Response<Body>, Error = failure::Error> + Send>;
 
-type ApiHandlerFn = fn(Value, &ApiMethod) -> Result<Value, Error>;
+pub trait RpcEnvironment {
+
+    fn set_result_attrib(&mut self, name: &str, value: Value);
+
+    fn get_result_attrib(&self, name: &str) -> Option<&Value>;
+}
+
+type ApiHandlerFn = fn(Value, &ApiMethod, &mut dyn RpcEnvironment) -> Result<Value, Error>;
 
 type ApiAsyncHandlerFn = fn(Parts, Body, Value, &ApiAsyncMethod) -> Result<BoxFut, Error>;