pajamax 0.4.0

Fast gRPC server framework in synchronous mode.
Documentation
#![doc = include_str!("../README.md")]

mod config;
mod connection;
mod hpack_decoder;
mod hpack_encoder;
mod http2;
mod huffman;
mod macros;

#[doc(hidden)]
pub mod dispatch;
#[doc(hidden)]
pub mod error;
#[doc(hidden)]
pub mod response_end;

pub mod status;
pub use config::{Config, ConfigedServer};

#[doc(hidden)]
pub use connection::local_build_response;
#[doc(hidden)]
pub use http2::ReplyEncode;

/// Wrapper of `Result<Reply, status::Status>`.
pub type Response<Reply> = Result<Reply, status::Status>;

#[doc(hidden)]
/// Used by pajamax-build crate.
pub trait PajamaxService {
    // Route the path to request enum discriminant as usize.
    // It does not return the request enum itself because
    // of multiple services have different requests.
    fn route(&self, path: &[u8]) -> Option<usize>;

    // Handle the request:
    // 1. parse the request from req_disc(from route()) and req_buf,
    // 2. call the method defined in applications and make reply,
    // 3. response the reply to resp_end.
    //
    // We merge these steps into one function because it's difficult
    // to abstract exactly same routine for both local-mode and
    // dispatch-mode. So we move the implemention to pajamax-build
    // crate.
    fn handle(&self, req_disc: usize, req_buf: &[u8], stream_id: u32) -> Result<(), error::Error>;

    // Take `self` for object-safe.
    fn is_dispatch_mode(&self) -> bool;
}