Skip to content

Commit

Permalink
Compat with latest embedded-svc
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed Oct 10, 2023
1 parent 4694312 commit 84d43e8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 53 deletions.
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
name = "edge-net"
version = "0.3.0"
authors = ["Ivan Markov <[email protected]>"]
edition = "2018"
resolver = "2"
edition = "2021"
categories = ["embedded", "hardware-support"]
keywords = ["embedded", "svc", "network"]
description = "no_std and no-alloc async implementations of various network protocols."
repository = "https://github.com/ivmarkov/edge-net"
license = "MIT OR Apache-2.0"
readme = "README.md"
rust-version = "1.67"
rust-version = "1.70"

[patch.crates-io]
embedded-svc = { git = "https://github.com/esp-rs/embedded-svc" }
Expand Down
19 changes: 0 additions & 19 deletions examples/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ impl SimpleHandler {
}
}

#[cfg(version("1.67"))]
impl<'b, const N: usize, T> Handler<'b, N, T> for SimpleHandler
where
T: Read + Write,
Expand All @@ -98,21 +97,3 @@ where
SimpleHandler::handle(self, path, method, connection).await
}
}

#[cfg(not(version("1.67")))]
impl<'b, const N: usize, T> Handler<'b, N, T> for SimpleHandler
where
T: Read + Write,
{
type HandleFuture<'a> = impl core::future::Future<Output = Result<(), HandlerError>> + 'a
where Self: 'a, 'b: 'a, T: 'a;

fn handle<'a>(
&'a self,
path: &'a str,
method: Method,
connection: &'a mut ServerConnection<'b, N, T>,
) -> Self::HandleFuture<'a> {
SimpleHandler::handle(self, path, method, connection)
}
}
19 changes: 0 additions & 19 deletions src/asynch/http/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ pub struct RequestState<'b, const N: usize, T> {

pub type ResponseState<T> = SendBody<T>;

#[cfg(version("1.67"))]
pub trait Handler<'b, const N: usize, T> {
async fn handle<'a>(
&'a self,
Expand All @@ -270,24 +269,6 @@ pub trait Handler<'b, const N: usize, T> {
) -> Result<(), HandlerError>;
}

// Does not typecheck with latest nightly 1.67
// See https://github.com/rust-lang/rust/issues/104691
#[cfg(not(version("1.67")))]
pub trait Handler<'b, const N: usize, T> {
type HandleFuture<'a>: Future<Output = Result<(), HandlerError>>
where
Self: 'a,
'b: 'a,
T: 'a;

fn handle<'a>(
&'a self,
path: &'a str,
method: Method,
connection: &'a mut ServerConnection<'b, N, T>,
) -> Self::HandleFuture<'a>;
}

pub async fn handle_connection<const N: usize, const B: usize, T, H>(
mut io: T,
handler_id: usize,
Expand Down
17 changes: 5 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(stable_features)]
#![feature(cfg_version)]
#![cfg_attr(feature = "nightly", feature(type_alias_impl_trait))]
#![cfg_attr(
all(feature = "nightly", version("1.70")),
feature(impl_trait_in_assoc_type)
)]
#![cfg_attr(
feature = "nightly",
feature(async_fn_in_trait),
feature(impl_trait_projections),
allow(incomplete_features)
)]
#![allow(unknown_lints)]
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait))]
#![cfg_attr(feature = "nightly", allow(async_fn_in_trait))]
#![cfg_attr(feature = "nightly", feature(impl_trait_projections))]
#![cfg_attr(feature = "nightly", feature(impl_trait_in_assoc_type))]

#[cfg(feature = "nightly")]
pub mod asynch;
Expand Down

0 comments on commit 84d43e8

Please sign in to comment.