Skip to content

Commit 71c0858

Browse files
committed
embedded-svc compat
1 parent c109398 commit 71c0858

File tree

4 files changed

+38
-237
lines changed

4 files changed

+38
-237
lines changed

edge-http/src/io/client.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ mod embedded_svc_compat {
473473

474474
use embedded_svc::http::client::asynch::{Connection, Headers, Method, Status};
475475

476-
impl<'b, T, const N: usize> Headers for super::Connection<'b, T, N>
476+
impl<T, const N: usize> Headers for super::Connection<'_, T, N>
477477
where
478478
T: TcpConnect,
479479
{
@@ -484,7 +484,7 @@ mod embedded_svc_compat {
484484
}
485485
}
486486

487-
impl<'b, T, const N: usize> Status for super::Connection<'b, T, N>
487+
impl<T, const N: usize> Status for super::Connection<'_, T, N>
488488
where
489489
T: TcpConnect,
490490
{

edge-http/src/io/server.rs

+31-50
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ pub use embedded_svc_compat::*;
2323
pub const DEFAULT_HANDLER_TASKS_COUNT: usize = 4;
2424
pub const DEFAULT_BUF_SIZE: usize = 2048;
2525

26-
pub mod registration;
27-
2826
const COMPLETION_BUF_SIZE: usize = 64;
2927

3028
/// A connection state machine for handling HTTP server requests-response cycles.
@@ -680,14 +678,11 @@ mod embedded_svc_compat {
680678
use embedded_io_async::{Read, Write};
681679

682680
use embedded_svc::http::server::asynch::{Connection, Headers, Query};
683-
use embedded_svc::utils::http::server::registration::{ChainHandler, ChainRoot};
684681

685682
use crate::io::Body;
686683
use crate::RequestHeaders;
687684

688-
use super::*;
689-
690-
impl<'b, T, const N: usize> Headers for super::Connection<'b, T, N>
685+
impl<T, const N: usize> Headers for super::Connection<'_, T, N>
691686
where
692687
T: Read + Write,
693688
{
@@ -699,7 +694,7 @@ mod embedded_svc_compat {
699694
}
700695
}
701696

702-
impl<'b, T, const N: usize> Query for super::Connection<'b, T, N>
697+
impl<T, const N: usize> Query for super::Connection<'_, T, N>
703698
where
704699
T: Read + Write,
705700
{
@@ -755,47 +750,33 @@ mod embedded_svc_compat {
755750
}
756751
}
757752

758-
impl<'b, T, const N: usize> Handler<'b, T, N> for ChainRoot
759-
where
760-
T: Read + Write,
761-
{
762-
type Error = Error<T::Error>;
763-
764-
async fn handle(
765-
&self,
766-
_task_id: impl core::fmt::Display + Copy,
767-
connection: &mut super::Connection<'b, T, N>,
768-
) -> Result<(), Self::Error> {
769-
connection.initiate_response(404, None, &[]).await
770-
}
771-
}
772-
773-
impl<'b, const N: usize, T, H, Q> Handler<'b, T, N> for ChainHandler<H, Q>
774-
where
775-
H: embedded_svc::http::server::asynch::Handler<super::Connection<'b, T, N>>,
776-
Q: Handler<'b, T, N>,
777-
Q::Error: Into<H::Error>,
778-
T: Read + Write,
779-
{
780-
type Error = H::Error;
781-
782-
async fn handle(
783-
&self,
784-
task_id: impl core::fmt::Display + Copy,
785-
connection: &mut super::Connection<'b, T, N>,
786-
) -> Result<(), Self::Error> {
787-
let headers = connection.headers().ok();
788-
789-
if let Some(headers) = headers {
790-
if headers.path == self.path && headers.method == self.method.into() {
791-
return self.handler.handle(connection).await;
792-
}
793-
}
794-
795-
self.next
796-
.handle(task_id, connection)
797-
.await
798-
.map_err(Into::into)
799-
}
800-
}
753+
// NOTE: Currently, the `edge-http` and the `embedded-svc` Handler traits are
754+
// incompatible, in that the `edge-http` async `Handler`'s `handle` method is generic,
755+
// while the `embedded-svc` `Handler`'s `handle` method is not.
756+
//
757+
// Code below is commented out until `embedded-svc`'s `Handler` signature is changed
758+
// to match the `edge-http` `Handler` signature.
759+
760+
// pub struct SvcHandler<H>(H);
761+
762+
// impl<'b, T, const N: usize, H> Handler for SvcHandler<H>
763+
// where
764+
// H: embedded_svc::http::server::asynch::Handler<super::Connection<'b, T, N>>,
765+
// T: Read + Write,
766+
// {
767+
// type Error<E> = Error<E> where E: Debug;
768+
769+
// async fn handle<T, const N: usize>(
770+
// &self,
771+
// _task_id: impl core::fmt::Display + Copy,
772+
// connection: &mut super::Connection<'_, T, N>,
773+
// ) -> Result<(), Self::Error<T::Error>>
774+
// where
775+
// T: Read + Write,
776+
// {
777+
// self.0.handle(connection).await.unwrap();
778+
779+
// Ok(())
780+
// }
781+
// }
801782
}

edge-http/src/io/server/registration.rs

-180
This file was deleted.

edge-http/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,7 @@ mod embedded_svc_compat {
14111411
}
14121412
}
14131413

1414-
impl<'b, const N: usize> embedded_svc::http::Query for super::RequestHeaders<'b, N> {
1414+
impl<const N: usize> embedded_svc::http::Query for super::RequestHeaders<'_, N> {
14151415
fn uri(&self) -> &'_ str {
14161416
self.path
14171417
}
@@ -1421,13 +1421,13 @@ mod embedded_svc_compat {
14211421
}
14221422
}
14231423

1424-
impl<'b, const N: usize> embedded_svc::http::Headers for super::RequestHeaders<'b, N> {
1424+
impl<const N: usize> embedded_svc::http::Headers for super::RequestHeaders<'_, N> {
14251425
fn header(&self, name: &str) -> Option<&'_ str> {
14261426
self.headers.get(name)
14271427
}
14281428
}
14291429

1430-
impl<'b, const N: usize> embedded_svc::http::Status for super::ResponseHeaders<'b, N> {
1430+
impl<const N: usize> embedded_svc::http::Status for super::ResponseHeaders<'_, N> {
14311431
fn status(&self) -> u16 {
14321432
self.code
14331433
}
@@ -1437,13 +1437,13 @@ mod embedded_svc_compat {
14371437
}
14381438
}
14391439

1440-
impl<'b, const N: usize> embedded_svc::http::Headers for super::ResponseHeaders<'b, N> {
1440+
impl<const N: usize> embedded_svc::http::Headers for super::ResponseHeaders<'_, N> {
14411441
fn header(&self, name: &str) -> Option<&'_ str> {
14421442
self.headers.get(name)
14431443
}
14441444
}
14451445

1446-
impl<'b, const N: usize> embedded_svc::http::Headers for super::Headers<'b, N> {
1446+
impl<const N: usize> embedded_svc::http::Headers for super::Headers<'_, N> {
14471447
fn header(&self, name: &str) -> Option<&'_ str> {
14481448
self.get(name)
14491449
}

0 commit comments

Comments
 (0)