use crate::mailbox::{MailboxParser, MailboxReq};
use http_pool::body::VariantBody;
use http_pool::net_pool::{Pool, Pools};
use hyper::body::{Bytes, Incoming};
use hyper::{Request, Response};
pub struct JsonMailboxParser;
impl MailboxParser for JsonMailboxParser {
type Error = serde_json::Error;
fn parse(data: Bytes, _zip: Option<String>) -> Result<MailboxReq, Self::Error> {
serde_json::from_slice(data.as_ref())
}
}
pub async fn send_to_mailbox<P: Pool>(
builder: &kmailbox::Builder,
pools: Pools<P>,
req: Request<Incoming>,
) -> Result<(Response<VariantBody>, Option<anyhow::Error>), anyhow::Error> {
crate::mailbox::send_to_mailbox::<P, JsonMailboxParser>(builder, pools, req).await
}