rpc_adapter 0.1.2

English: RPC adapter for unified request handling / 中文: 统一请求处理的RPC适配器
Documentation
#![cfg_attr(docsrs, feature(doc_cfg))]

use http::Extensions;

pub trait Map {
  fn get(&self, key: impl AsRef<str>) -> Option<&str>;
}

pub trait Req {
  fn headers(&self) -> impl Map;
  fn extensions(&self) -> &Extensions;
  fn extensions_mut(&mut self) -> &mut Extensions;
}

pub struct Res {
  pub code: u16,
  pub body: Vec<u8>,
}

impl std::error::Error for Res {}

impl std::fmt::Display for Res {
  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
    write!(f, "Res {}", self.code)
  }
}

impl std::fmt::Debug for Res {
  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
    std::fmt::Display::fmt(self, f)
  }
}

#[cfg(feature = "volo-grpc")]
pub mod impl_volo_grpc;

#[cfg(feature = "volo-http")]
pub mod impl_volo_http;