use async_trait::async_trait;
use bytes::Bytes;
use thiserror::Error;
#[derive(Debug, Clone, Error)]
pub enum DispatchError {
#[error("no service binding named `{0}`")]
NotBound(String),
#[error("sidecar `{binding}` did not answer: {reason}")]
Unavailable { binding: String, reason: String },
}
#[async_trait]
pub trait Dispatcher: Send + Sync {
fn has(&self, binding: &str) -> bool;
async fn dispatch(
&self,
binding: &str,
request: http::Request<Bytes>,
) -> Result<http::Response<Bytes>, DispatchError>;
}