1#![deny(warnings, rust_2018_idioms)]
2
3mod distribution;
4pub mod latency;
5pub mod limit;
6
7pub use self::{
8 distribution::Distribution,
9 latency::{parse_duration, InvalidDuration, Latency},
10};
11use bytes::Bytes;
12use std::time::Duration;
13
14#[async_trait::async_trait]
15pub trait MakeOrt<T>: Clone + Send + 'static {
16 type Ort: Ort;
17 async fn make_ort(&mut self, target: T) -> Result<Self::Ort, Error>;
18}
19
20#[async_trait::async_trait]
21pub trait Ort: Clone + Send + 'static {
22 async fn ort(&mut self, spec: Spec) -> Result<Reply, Error>;
23}
24
25pub type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
26
27#[derive(Copy, Clone, Debug, Default, PartialEq)]
28#[cfg_attr(feature = "deser", derive(serde::Serialize, serde::Deserialize))]
29pub struct Spec {
30 pub latency: Duration,
31 pub response_size: usize,
32}
33
34#[derive(Clone, Debug, Default, PartialEq)]
35#[cfg_attr(feature = "deser", derive(serde::Serialize, serde::Deserialize))]
36pub struct Reply {
37 pub data: Bytes,
38}