make OsApi manager-based

This commit is contained in:
Aiden McClelland
2023-02-01 18:42:32 -07:00
parent bec307d0e9
commit 550b17552b
5 changed files with 52 additions and 34 deletions

View File

@@ -1,3 +1,4 @@
use color_eyre::eyre::eyre;
use models::Error;
use models::PackageId;
use serde_json::Value;
@@ -6,12 +7,22 @@ pub struct RuntimeDropped;
pub type Callback = Box<dyn Fn(Value) -> Result<(), RuntimeDropped> + Send + Sync + 'static>; // bool indicating if
fn method_not_available() -> Error {
Error::new(
eyre!("method not available"),
models::ErrorKind::InvalidRequest,
)
}
#[async_trait::async_trait]
#[allow(unused_variables)]
pub trait OsApi: Send + Sync + 'static {
async fn get_service_config(
&self,
id: PackageId,
path: &str,
callback: Callback,
) -> Result<Value, Error>;
) -> Result<Value, Error> {
Err(method_not_available())
}
}