mod error;
mod router;
pub use error::*;
pub use http::Extensions;
pub use router::{Router, ServerHandle};
#[trait_variant::make(Send)]
pub trait FromRequestExtensions<Ctx>
where
Self: Sized,
{
async fn from_request_extensions(ctx: Ctx, extensions: Extensions) -> Result<Self, RpcError>;
}
impl<Ctx: Send> FromRequestExtensions<Ctx> for Ctx {
async fn from_request_extensions(ctx: Ctx, _extensions: Extensions) -> Result<Self, RpcError> {
Ok(ctx)
}
}
#[derive(Clone, Copy, Debug)]
pub(crate) enum RequestKind {
Query,
Mutation,
Any,
}
impl PartialEq for RequestKind {
fn eq(&self, other: &Self) -> bool {
matches!(
(self, other),
(Self::Any, _)
| (_, Self::Any)
| (Self::Query, Self::Query)
| (Self::Mutation, Self::Mutation)
)
}
}