1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use crate::errors::*;
use crate::reqrep::{ORequest, OResponse, TFRequest, TFResponse};
use async_trait::async_trait;
pub(crate) trait Service {
fn load(&mut self) -> Result<()>;
}
#[async_trait]
pub(crate) trait TensorflowAsyncService {
async fn async_process(&self, request: ORequest<TFRequest>) -> Result<OResponse<TFResponse>>;
}
cfg_if::cfg_if! {
if #[cfg(feature = "pymodel")] {
use pyo3::{PyObject, ToPyObject};
use crate::reqrep::PyModelRequest;
#[async_trait]
pub(crate) trait PythonAsyncService {
async fn async_process<K: 'static, V: 'static, T: 'static>(
&self,
request: ORequest<PyModelRequest<K, V, T>>,
) -> Self::FutType
where
K: hash::Hash + cmp::Eq + Default + ToPyObject + Send,
V: Default + ToPyObject + Send,
T: Default + ToPyObject + Send;
}
} else if #[cfg(feature = "onnxmodel")] {
use crate::reqrep::{ONNXRequest, ONNXResponse};
#[async_trait]
pub(crate) trait ONNXAsyncService {
async fn async_process(
&self,
request: ORequest<ONNXRequest>,
) -> Result<OResponse<ONNXResponse>>;
}
}
}