1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-01-18 13:01:49 +01:00

bump MSRV to 1.65 (#485)

This commit is contained in:
Rob Ede 2023-07-17 03:05:39 +01:00 committed by GitHub
parent 177590a7d8
commit 8d5d1dbf6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
60 changed files with 188 additions and 229 deletions

View File

@ -23,7 +23,7 @@ jobs:
- { name: Windows (MinGW), os: windows-latest, triple: x86_64-pc-windows-gnu }
- { name: Windows (32-bit), os: windows-latest, triple: i686-pc-windows-msvc }
version:
- 1.60.0
- 1.65.0 # MSRV
- stable
name: ${{ matrix.target.name }} / ${{ matrix.version }}

3
.rustfmt.toml Normal file
View File

@ -0,0 +1,3 @@
group_imports = "StdExternalCrate"
imports_granularity = "Crate"
use_field_init_shorthand = true

View File

@ -14,6 +14,10 @@ members = [
]
resolver = "2"
[workspace.package]
edition = "2021"
rust-version = "1.65"
[patch.crates-io]
actix-codec = { path = "actix-codec" }
actix-macros = { path = "actix-macros" }

View File

@ -13,7 +13,7 @@ See example folders for [`actix-server`](./actix-server/examples) and [`actix-tl
## MSRV
Crates in this repo currently have a Minimum Supported Rust Version (MSRV) of 1.60. As a policy, we permit MSRV increases in non-breaking releases.
Crates in this repo currently have a Minimum Supported Rust Version (MSRV) of 1.65. As a policy, we permit MSRV increases in non-breaking releases.
## License

View File

@ -2,7 +2,7 @@
## Unreleased - 2023-xx-xx
- Minimum supported Rust version (MSRV) is now 1.60.
- Minimum supported Rust version (MSRV) is now 1.65.
## 0.5.1 - 2022-03-15

View File

@ -10,8 +10,8 @@ keywords = ["network", "framework", "async", "futures"]
repository = "https://github.com/actix/actix-net"
categories = ["network-programming", "asynchronous"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.60"
edition.workspace = true
rust-version.workspace = true
[dependencies]
bitflags = "2"

View File

@ -234,10 +234,7 @@ impl<T, U> Framed<T, U> {
}
/// Flush write buffer to underlying I/O stream.
pub fn flush<I>(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), U::Error>>
pub fn flush<I>(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), U::Error>>
where
T: AsyncWrite,
U: Encoder<I>,
@ -270,10 +267,7 @@ impl<T, U> Framed<T, U> {
}
/// Flush write buffer and shutdown underlying I/O stream.
pub fn close<I>(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), U::Error>>
pub fn close<I>(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), U::Error>>
where
T: AsyncWrite,
U: Encoder<I>,

View File

@ -11,14 +11,18 @@
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
pub use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
pub use tokio_util::{
codec::{Decoder, Encoder},
io::poll_read_buf,
};
mod bcodec;
mod framed;
mod lines;
pub use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
pub use tokio_util::codec::{Decoder, Encoder};
pub use tokio_util::io::poll_read_buf;
pub use self::bcodec::BytesCodec;
pub use self::framed::{Framed, FramedParts};
pub use self::lines::LinesCodec;
pub use self::{
bcodec::BytesCodec,
framed::{Framed, FramedParts},
lines::LinesCodec,
};

View File

@ -81,10 +81,7 @@ impl AsyncWrite for Bilateral {
other => Ready(other),
}
}
fn poll_shutdown(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
) -> Poll<Result<(), io::Error>> {
fn poll_shutdown(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
unimplemented!()
}
}

View File

@ -3,7 +3,7 @@
## Unreleased - 2023-xx-xx
- Update `syn` dependency to `2`.
- Minimum supported Rust version (MSRV) is now 1.60.
- Minimum supported Rust version (MSRV) is now 1.65.
## 0.2.3 - 2021-10-19

View File

@ -10,8 +10,8 @@ description = "Macros for Actix system and runtime"
repository = "https://github.com/actix/actix-net.git"
categories = ["network-programming", "asynchronous"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.60"
edition.workspace = true
rust-version.workspace = true
[lib]
proc-macro = true

View File

@ -1,4 +1,4 @@
#[rustversion::stable(1.60)] // MSRV
#[rustversion::stable(1.65)] // MSRV
#[test]
fn compile_macros() {
let t = trybuild::TestCases::new();

View File

@ -1,14 +1,11 @@
error: the async keyword is missing from the function declaration
--> $DIR/main-02-only-async.rs:2:1
--> tests/trybuild/main-02-only-async.rs:2:1
|
2 | fn main() {
| ^^
error[E0601]: `main` function not found in crate `$CRATE`
--> $DIR/main-02-only-async.rs:1:1
--> tests/trybuild/main-02-only-async.rs:4:2
|
1 | / #[actix_rt::main]
2 | | fn main() {
3 | | futures_util::future::ready(()).await
4 | | }
| |_^ consider adding a `main` function to `$DIR/tests/trybuild/main-02-only-async.rs`
4 | }
| ^ consider adding a `main` function to `$DIR/tests/trybuild/main-02-only-async.rs`

View File

@ -2,7 +2,7 @@
## Unreleased - 2023-xx-xx
- Minimum supported Rust version (MSRV) is now 1.60.
- Minimum supported Rust version (MSRV) is now 1.65.
## 2.8.0 - 2022-12-21

View File

@ -11,8 +11,8 @@ homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git"
categories = ["network-programming", "asynchronous"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.60"
edition.workspace = true
rust-version.workspace = true
[features]
default = ["macros"]

View File

@ -20,8 +20,7 @@ fn main() {
let make_service =
make_service_fn(|_conn| async { Ok::<_, Infallible>(service_fn(handle)) });
let server =
Server::bind(&SocketAddr::from(([127, 0, 0, 1], 3000))).serve(make_service);
let server = Server::bind(&SocketAddr::from(([127, 0, 0, 1], 3000))).serve(make_service);
if let Err(err) = server.await {
eprintln!("server error: {}", err);

View File

@ -99,8 +99,7 @@ impl Arbiter {
#[allow(clippy::new_without_default)]
pub fn new() -> Arbiter {
Self::with_tokio_rt(|| {
crate::runtime::default_tokio_runtime()
.expect("Cannot create new Arbiter's Runtime.")
crate::runtime::default_tokio_runtime().expect("Cannot create new Arbiter's Runtime.")
})
}
@ -149,9 +148,7 @@ impl Arbiter {
.send(SystemCommand::DeregisterArbiter(arb_id));
}
})
.unwrap_or_else(|err| {
panic!("Cannot spawn Arbiter's thread: {:?}. {:?}", &name, err)
});
.unwrap_or_else(|err| panic!("Cannot spawn Arbiter's thread: {name:?}: {err:?}"));
ready_rx.recv().unwrap();
@ -201,9 +198,7 @@ impl Arbiter {
.send(SystemCommand::DeregisterArbiter(arb_id));
}
})
.unwrap_or_else(|err| {
panic!("Cannot spawn Arbiter's thread: {:?}. {:?}", &name, err)
});
.unwrap_or_else(|err| panic!("Cannot spawn Arbiter's thread: {name:?}: {err:?}"));
ready_rx.recv().unwrap();

View File

@ -65,9 +65,11 @@ mod system;
pub use tokio::pin;
use tokio::task::JoinHandle;
pub use self::arbiter::{Arbiter, ArbiterHandle};
pub use self::runtime::Runtime;
pub use self::system::{System, SystemRunner};
pub use self::{
arbiter::{Arbiter, ArbiterHandle},
runtime::Runtime,
system::{System, SystemRunner},
};
pub mod signal {
//! Asynchronous signal handling (Tokio re-exports).
@ -89,12 +91,13 @@ pub mod net {
task::{Context, Poll},
};
pub use tokio::io::Ready;
use tokio::io::{AsyncRead, AsyncWrite, Interest};
pub use tokio::net::UdpSocket;
pub use tokio::net::{TcpListener, TcpSocket, TcpStream};
#[cfg(unix)]
pub use tokio::net::{UnixDatagram, UnixListener, UnixStream};
pub use tokio::{
io::Ready,
net::{TcpListener, TcpSocket, TcpStream, UdpSocket},
};
/// Extension trait over async read+write types that can also signal readiness.
#[doc(hidden)]
@ -153,10 +156,9 @@ pub mod net {
pub mod time {
//! Utilities for tracking time (Tokio re-exports).
pub use tokio::time::Instant;
pub use tokio::time::{interval, interval_at, Interval};
pub use tokio::time::{sleep, sleep_until, Sleep};
pub use tokio::time::{timeout, Timeout};
pub use tokio::time::{
interval, interval_at, sleep, sleep_until, timeout, Instant, Interval, Sleep, Timeout,
};
}
pub mod task {

View File

@ -226,9 +226,7 @@ impl SystemRunner {
/// Runs the event loop until [stopped](System::stop_with_code), returning the exit code.
pub fn run_with_code(self) -> io::Result<i32> {
unimplemented!(
"SystemRunner::run_with_code is not implemented for io-uring feature yet"
);
unimplemented!("SystemRunner::run_with_code is not implemented for io-uring feature yet");
}
/// Runs the provided future, blocking the current thread until the future completes.

View File

@ -2,7 +2,7 @@
## Unreleased - 2023-xx-xx
- Minimum supported Rust version (MSRV) is now 1.60.
- Minimum supported Rust version (MSRV) is now 1.65.
## 2.2.0 - 2022-12-21

View File

@ -12,8 +12,8 @@ categories = ["network-programming", "asynchronous"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git"
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.60"
edition.workspace = true
rust-version.workspace = true
[features]
default = []
@ -28,7 +28,7 @@ futures-core = { version = "0.3.17", default-features = false, features = ["allo
futures-util = { version = "0.3.17", default-features = false, features = ["alloc"] }
mio = { version = "0.8", features = ["os-poll", "net"] }
num_cpus = "1.13"
socket2 = "0.4.2" # TODO(MSRV 1.64) update to 0.5
socket2 = "0.5"
tokio = { version = "1.23.1", features = ["sync"] }
tracing = { version = "0.1.30", default-features = false, features = ["log"] }

View File

@ -7,9 +7,7 @@ use tracing::{info, trace};
use crate::{
server::ServerCommand,
service::{InternalServiceFactory, ServerServiceFactory, StreamNewService},
socket::{
create_mio_tcp_listener, MioListener, MioTcpListener, StdTcpListener, ToSocketAddrs,
},
socket::{create_mio_tcp_listener, MioListener, MioTcpListener, StdTcpListener, ToSocketAddrs},
worker::ServerWorkerConfig,
Server,
};
@ -246,8 +244,7 @@ impl ServerBuilder {
use std::net::{IpAddr, Ipv4Addr};
lst.set_nonblocking(true)?;
let token = self.next_token();
let addr =
crate::socket::StdSocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
let addr = crate::socket::StdSocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
self.factories.push(StreamNewService::create(
name.as_ref().to_string(),
token,

View File

@ -18,13 +18,12 @@ mod test_server;
mod waker_queue;
mod worker;
pub use self::builder::ServerBuilder;
pub use self::handle::ServerHandle;
pub use self::server::Server;
pub use self::service::ServerServiceFactory;
#[doc(hidden)]
pub use self::socket::FromStream;
pub use self::test_server::TestServer;
pub use self::{
builder::ServerBuilder, handle::ServerHandle, server::Server, service::ServerServiceFactory,
test_server::TestServer,
};
/// Start server building process
#[doc(hidden)]

View File

@ -78,7 +78,7 @@ where
Ok(())
}
Err(err) => {
error!("can not convert to an async TCP stream: {}", err);
error!("can not convert to an async TCP stream: {err}");
Err(())
}
})

View File

@ -8,8 +8,7 @@ pub(crate) use mio::net::TcpListener as MioTcpListener;
use mio::{event::Source, Interest, Registry, Token};
#[cfg(unix)]
pub(crate) use {
mio::net::UnixListener as MioUnixListener,
std::os::unix::net::UnixListener as StdUnixListener,
mio::net::UnixListener as MioUnixListener, std::os::unix::net::UnixListener as StdUnixListener,
};
pub(crate) enum MioListener {
@ -105,7 +104,7 @@ impl fmt::Debug for MioListener {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
MioListener::Tcp(ref lst) => write!(f, "{:?}", lst),
#[cfg(all(unix))]
#[cfg(unix)]
MioListener::Uds(ref lst) => write!(f, "{:?}", lst),
}
}

View File

@ -625,8 +625,8 @@ impl Future for ServerWorker {
let factory_id = restart.factory_id;
let token = restart.token;
let (token_new, service) = ready!(restart.fut.as_mut().poll(cx))
.unwrap_or_else(|_| {
let (token_new, service) =
ready!(restart.fut.as_mut().poll(cx)).unwrap_or_else(|_| {
panic!(
"Can not restart {:?} service",
this.factories[factory_id].name(token)
@ -697,7 +697,10 @@ impl Future for ServerWorker {
match ready!(this.conn_rx.poll_recv(cx)) {
Some(msg) => {
let guard = this.counter.guard();
let _ = this.services[msg.token].service.call((guard, msg.io));
let _ = this.services[msg.token]
.service
.call((guard, msg.io))
.into_inner();
}
None => return Poll::Ready(()),
};
@ -706,9 +709,7 @@ impl Future for ServerWorker {
}
}
fn wrap_worker_services(
services: Vec<(usize, usize, BoxedServerService)>,
) -> Vec<WorkerService> {
fn wrap_worker_services(services: Vec<(usize, usize, BoxedServerService)>) -> Vec<WorkerService> {
services
.into_iter()
.fold(Vec::new(), |mut services, (idx, token, service)| {

View File

@ -2,7 +2,7 @@
## Unreleased - 2023-xx-xx
- Minimum supported Rust version (MSRV) is now 1.60.
- Minimum supported Rust version (MSRV) is now 1.65.
## 2.0.2 - 2021-12-18

View File

@ -10,8 +10,8 @@ keywords = ["network", "framework", "async", "futures", "service"]
categories = ["network-programming", "asynchronous", "no-std"]
repository = "https://github.com/actix/actix-net"
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.60"
edition.workspace = true
rust-version.workspace = true
[dependencies]
futures-core = { version = "0.3.17", default-features = false }

View File

@ -121,12 +121,7 @@ pub struct AndThenServiceFactory<A, B, Req>
where
A: ServiceFactory<Req>,
A::Config: Clone,
B: ServiceFactory<
A::Response,
Config = A::Config,
Error = A::Error,
InitError = A::InitError,
>,
B: ServiceFactory<A::Response, Config = A::Config, Error = A::Error, InitError = A::InitError>,
{
inner: Rc<(A, B)>,
_phantom: PhantomData<Req>,
@ -136,12 +131,7 @@ impl<A, B, Req> AndThenServiceFactory<A, B, Req>
where
A: ServiceFactory<Req>,
A::Config: Clone,
B: ServiceFactory<
A::Response,
Config = A::Config,
Error = A::Error,
InitError = A::InitError,
>,
B: ServiceFactory<A::Response, Config = A::Config, Error = A::Error, InitError = A::InitError>,
{
/// Create new `AndThenFactory` combinator
pub(crate) fn new(a: A, b: B) -> Self {
@ -156,12 +146,7 @@ impl<A, B, Req> ServiceFactory<Req> for AndThenServiceFactory<A, B, Req>
where
A: ServiceFactory<Req>,
A::Config: Clone,
B: ServiceFactory<
A::Response,
Config = A::Config,
Error = A::Error,
InitError = A::InitError,
>,
B: ServiceFactory<A::Response, Config = A::Config, Error = A::Error, InitError = A::InitError>,
{
type Response = B::Response;
type Error = A::Error;
@ -184,12 +169,7 @@ impl<A, B, Req> Clone for AndThenServiceFactory<A, B, Req>
where
A: ServiceFactory<Req>,
A::Config: Clone,
B: ServiceFactory<
A::Response,
Config = A::Config,
Error = A::Error,
InitError = A::InitError,
>,
B: ServiceFactory<A::Response, Config = A::Config, Error = A::Error, InitError = A::InitError>,
{
fn clone(&self) -> Self {
Self {
@ -334,8 +314,7 @@ mod tests {
async fn test_new_service() {
let cnt = Rc::new(Cell::new(0));
let cnt2 = cnt.clone();
let new_srv =
pipeline_factory(fn_factory(move || ready(Ok::<_, ()>(Srv1(cnt2.clone())))))
let new_srv = pipeline_factory(fn_factory(move || ready(Ok::<_, ()>(Srv1(cnt2.clone())))))
.and_then(move || ready(Ok(Srv2(cnt.clone()))));
let srv = new_srv.new_service(()).await.unwrap();

View File

@ -140,8 +140,7 @@ where
}
}
impl<SF, F, Fut, Req, In, Res, Err> ServiceFactory<Req>
for ApplyFactory<SF, F, Req, In, Res, Err>
impl<SF, F, Fut, Req, In, Res, Err> ServiceFactory<Req> for ApplyFactory<SF, F, Req, In, Res, Err>
where
SF: ServiceFactory<In, Error = Err>,
F: Fn(Req, &SF::Service) -> Fut + Clone,

View File

@ -198,8 +198,7 @@ pin_project! {
}
}
impl<SF, Req, F, Cfg, Fut, S> Future
for ApplyConfigServiceFactoryResponse<SF, Req, F, Cfg, Fut, S>
impl<SF, Req, F, Cfg, Fut, S> Future for ApplyConfigServiceFactoryResponse<SF, Req, F, Cfg, Fut, S>
where
SF: ServiceFactory<Req, Config = ()>,
SF::InitError: From<SF::Error>,

View File

@ -91,8 +91,7 @@ type Inner<C, Req, Res, Err, InitErr> = Box<
>,
>;
impl<C, Req, Res, Err, InitErr> ServiceFactory<Req>
for BoxServiceFactory<C, Req, Res, Err, InitErr>
impl<C, Req, Res, Err, InitErr> ServiceFactory<Req> for BoxServiceFactory<C, Req, Res, Err, InitErr>
where
Req: 'static,
Res: 'static,

View File

@ -3,9 +3,7 @@ use core::{future::Future, marker::PhantomData};
use crate::{ok, IntoService, IntoServiceFactory, Ready, Service, ServiceFactory};
/// Create `ServiceFactory` for function that can act as a `Service`
pub fn fn_service<F, Fut, Req, Res, Err, Cfg>(
f: F,
) -> FnServiceFactory<F, Fut, Req, Res, Err, Cfg>
pub fn fn_service<F, Fut, Req, Res, Err, Cfg>(f: F) -> FnServiceFactory<F, Fut, Req, Res, Err, Cfg>
where
F: Fn(Req) -> Fut + Clone,
Fut: Future<Output = Result<Res, Err>>,
@ -48,9 +46,7 @@ where
/// Ok(())
/// }
/// ```
pub fn fn_factory<F, Cfg, Srv, Req, Fut, Err>(
f: F,
) -> FnServiceNoConfig<F, Cfg, Srv, Req, Fut, Err>
pub fn fn_factory<F, Cfg, Srv, Req, Fut, Err>(f: F) -> FnServiceNoConfig<F, Cfg, Srv, Req, Fut, Err>
where
F: Fn() -> Fut,
Fut: Future<Output = Result<Srv, Err>>,
@ -265,8 +261,7 @@ where
}
}
impl<F, Fut, Cfg, Srv, Req, Err> ServiceFactory<Req>
for FnServiceConfig<F, Fut, Cfg, Srv, Req, Err>
impl<F, Fut, Cfg, Srv, Req, Err> ServiceFactory<Req> for FnServiceConfig<F, Fut, Cfg, Srv, Req, Err>
where
F: Fn(Cfg) -> Fut,
Fut: Future<Output = Result<Srv, Err>>,
@ -404,9 +399,8 @@ mod tests {
ok::<_, Rc<u8>>(fn_service(|_: Rc<u8>| ok::<_, Rc<u8>>(Rc::new(0u8))))
});
let fac_2 = fn_factory(|| {
ok::<_, Rc<u8>>(fn_service(|_: Rc<u8>| ok::<_, Rc<u8>>(Rc::new(0u8))))
});
let fac_2 =
fn_factory(|| ok::<_, Rc<u8>>(fn_service(|_: Rc<u8>| ok::<_, Rc<u8>>(Rc::new(0u8)))));
fn is_send<T: Send + Sync + Clone>(_: &T) {}

View File

@ -33,14 +33,16 @@ mod then;
mod transform;
mod transform_err;
pub use self::apply::{apply_fn, apply_fn_factory};
pub use self::apply_cfg::{apply_cfg, apply_cfg_factory};
pub use self::ext::{ServiceExt, ServiceFactoryExt, TransformExt};
pub use self::fn_service::{fn_factory, fn_factory_with_config, fn_service};
pub use self::map_config::{map_config, unit_config};
#[allow(unused_imports)]
use self::ready::{err, ok, ready, Ready};
pub use self::transform::{apply, ApplyTransform, Transform};
pub use self::{
apply::{apply_fn, apply_fn_factory},
apply_cfg::{apply_cfg, apply_cfg_factory},
ext::{ServiceExt, ServiceFactoryExt, TransformExt},
fn_service::{fn_factory, fn_factory_with_config, fn_service},
map_config::{map_config, unit_config},
transform::{apply, ApplyTransform, Transform},
};
/// An asynchronous operation from `Request` to a `Response`.
///

View File

@ -206,8 +206,7 @@ mod tests {
use super::*;
use crate::{
err, ok, IntoServiceFactory, Ready, Service, ServiceExt, ServiceFactory,
ServiceFactoryExt,
err, ok, IntoServiceFactory, Ready, Service, ServiceExt, ServiceFactory, ServiceFactoryExt,
};
struct Srv;

View File

@ -6,12 +6,14 @@ use core::{
task::{Context, Poll},
};
use crate::and_then::{AndThenService, AndThenServiceFactory};
use crate::map::{Map, MapServiceFactory};
use crate::map_err::{MapErr, MapErrServiceFactory};
use crate::map_init_err::MapInitErr;
use crate::then::{ThenService, ThenServiceFactory};
use crate::{IntoService, IntoServiceFactory, Service, ServiceFactory};
use crate::{
and_then::{AndThenService, AndThenServiceFactory},
map::{Map, MapServiceFactory},
map_err::{MapErr, MapErrServiceFactory},
map_init_err::MapInitErr,
then::{ThenService, ThenServiceFactory},
IntoService, IntoServiceFactory, Service, ServiceFactory,
};
/// Construct new pipeline with one service in pipeline chain.
pub(crate) fn pipeline<I, S, Req>(service: I) -> Pipeline<S, Req>
@ -252,10 +254,7 @@ where
}
/// Map this service's error to a different error, returning a new service.
pub fn map_err<F, E>(
self,
f: F,
) -> PipelineFactory<MapErrServiceFactory<SF, Req, F, E>, Req>
pub fn map_err<F, E>(self, f: F) -> PipelineFactory<MapErrServiceFactory<SF, Req, F, E>, Req>
where
Self: Sized,
F: Fn(SF::Error) -> E + Clone,

View File

@ -2,7 +2,7 @@
## Unreleased - 2023-xx-xx
- Minimum supported Rust version (MSRV) is now 1.60.
- Minimum supported Rust version (MSRV) is now 1.65.
## 3.0.4 - 2022-03-15

View File

@ -10,8 +10,8 @@ keywords = ["network", "tls", "ssl", "async", "transport"]
repository = "https://github.com/actix/actix-net.git"
categories = ["network-programming", "asynchronous", "cryptography"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.60"
edition.workspace = true
rust-version.workspace = true
[package.metadata.docs.rs]
all-features = true

View File

@ -56,6 +56,25 @@ pub enum TlsError<TlsErr, SvcErr> {
Service(SvcErr),
}
impl<TlsErr> TlsError<TlsErr, Infallible> {
/// Casts the infallible service error type returned from acceptors into caller's type.
///
/// # Examples
/// ```
/// # use std::convert::Infallible;
/// # use actix_tls::accept::TlsError;
/// let a: TlsError<u32, Infallible> = TlsError::Tls(42);
/// let _b: TlsError<u32, u64> = a.into_service_error();
/// ```
pub fn into_service_error<SvcErr>(self) -> TlsError<TlsErr, SvcErr> {
match self {
Self::Timeout => TlsError::Timeout,
Self::Tls(err) => TlsError::Tls(err),
Self::Service(err) => match err {},
}
}
}
impl<TlsErr, SvcErr> fmt::Display for TlsError<TlsErr, SvcErr> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
@ -80,25 +99,6 @@ where
}
}
impl<TlsErr> TlsError<TlsErr, Infallible> {
/// Casts the infallible service error type returned from acceptors into caller's type.
///
/// # Examples
/// ```
/// # use std::convert::Infallible;
/// # use actix_tls::accept::TlsError;
/// let a: TlsError<u32, Infallible> = TlsError::Tls(42);
/// let _b: TlsError<u32, u64> = a.into_service_error();
/// ```
pub fn into_service_error<SvcErr>(self) -> TlsError<TlsErr, SvcErr> {
match self {
Self::Timeout => TlsError::Timeout,
Self::Tls(err) => TlsError::Tls(err),
Self::Service(err) => match err {},
}
}
}
#[cfg(test)]
mod tests {
use super::*;

View File

@ -23,8 +23,7 @@ use actix_utils::{
};
use pin_project_lite::pin_project;
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
use tokio_rustls::rustls::ServerConfig;
use tokio_rustls::{Accept, TlsAcceptor};
use tokio_rustls::{rustls::ServerConfig, Accept, TlsAcceptor};
use super::{TlsError, DEFAULT_TLS_HANDSHAKE_TIMEOUT, MAX_CONN_COUNTER};

View File

@ -33,10 +33,12 @@ pub mod rustls;
#[cfg(feature = "native-tls")]
pub mod native_tls;
pub use self::connection::Connection;
pub use self::connector::{Connector, ConnectorService};
pub use self::error::ConnectError;
pub use self::host::Host;
pub use self::info::ConnectInfo;
pub use self::resolve::Resolve;
pub use self::resolver::{Resolver, ResolverService};
pub use self::{
connection::Connection,
connector::{Connector, ConnectorService},
error::ConnectError,
host::Host,
info::ConnectInfo,
resolve::Resolve,
resolver::{Resolver, ResolverService},
};

View File

@ -19,8 +19,7 @@ use crate::connect::{Connection, Host};
pub mod reexports {
//! Re-exports from `native-tls` and `tokio-native-tls` that are useful for connectors.
pub use tokio_native_tls::native_tls::TlsConnector;
pub use tokio_native_tls::TlsStream as AsyncTlsStream;
pub use tokio_native_tls::{native_tls::TlsConnector, TlsStream as AsyncTlsStream};
}
/// Connector service and factory using `native-tls`.

View File

@ -22,9 +22,7 @@ use crate::connect::{Connection, Host};
pub mod reexports {
//! Re-exports from `openssl` and `tokio-openssl` that are useful for connectors.
pub use openssl::ssl::{
Error, HandshakeError, SslConnector, SslConnectorBuilder, SslMethod,
};
pub use openssl::ssl::{Error, HandshakeError, SslConnector, SslConnectorBuilder, SslMethod};
pub use tokio_openssl::SslStream as AsyncSslStream;
}

View File

@ -15,9 +15,11 @@ use actix_rt::net::ActixStream;
use actix_service::{Service, ServiceFactory};
use actix_utils::future::{ok, Ready};
use futures_core::ready;
use tokio_rustls::rustls::{client::ServerName, OwnedTrustAnchor, RootCertStore};
use tokio_rustls::{client::TlsStream as AsyncTlsStream, rustls::ClientConfig};
use tokio_rustls::{Connect as RustlsConnect, TlsConnector as RustlsTlsConnector};
use tokio_rustls::{
client::TlsStream as AsyncTlsStream,
rustls::{client::ServerName, ClientConfig, OwnedTrustAnchor, RootCertStore},
Connect as RustlsConnect, TlsConnector as RustlsTlsConnector,
};
use tracing::trace;
use webpki_roots::TLS_SERVER_ROOTS;
@ -26,8 +28,7 @@ use crate::connect::{Connection, Host};
pub mod reexports {
//! Re-exports from `rustls` and `webpki_roots` that are useful for connectors.
pub use tokio_rustls::client::TlsStream as AsyncTlsStream;
pub use tokio_rustls::rustls::ClientConfig;
pub use tokio_rustls::{client::TlsStream as AsyncTlsStream, rustls::ClientConfig};
pub use webpki_roots::TLS_SERVER_ROOTS;
}

View File

@ -17,10 +17,8 @@ use actix_utils::future::ok;
use tokio_rustls::rustls::{Certificate, ClientConfig, RootCertStore, ServerName};
fn new_cert_and_key() -> (String, String) {
let cert = rcgen::generate_simple_self_signed(vec![
"127.0.0.1".to_owned(),
"localhost".to_owned(),
])
let cert =
rcgen::generate_simple_self_signed(vec!["127.0.0.1".to_owned(), "localhost".to_owned()])
.unwrap();
let key = cert.serialize_private_key_pem();

View File

@ -14,18 +14,18 @@ use std::io::{BufReader, Write};
use actix_rt::net::TcpStream;
use actix_server::TestServer;
use actix_service::ServiceFactoryExt as _;
use actix_tls::accept::rustls::{Acceptor, TlsStream};
use actix_tls::connect::openssl::reexports::SslConnector;
use actix_tls::{
accept::rustls::{Acceptor, TlsStream},
connect::openssl::reexports::SslConnector,
};
use actix_utils::future::ok;
use rustls_pemfile::{certs, pkcs8_private_keys};
use tls_openssl::ssl::SslVerifyMode;
use tokio_rustls::rustls::{self, Certificate, PrivateKey, ServerConfig};
fn new_cert_and_key() -> (String, String) {
let cert = rcgen::generate_simple_self_signed(vec![
"127.0.0.1".to_owned(),
"localhost".to_owned(),
])
let cert =
rcgen::generate_simple_self_signed(vec!["127.0.0.1".to_owned(), "localhost".to_owned()])
.unwrap();
let key = cert.serialize_private_key_pem();

View File

@ -51,8 +51,7 @@ async fn custom_resolver_connect() {
use trust_dns_resolver::TokioAsyncResolver;
let srv =
TestServer::start(|| fn_service(|_io: TcpStream| async { Ok::<_, io::Error>(()) }));
let srv = TestServer::start(|| fn_service(|_io: TcpStream| async { Ok::<_, io::Error>(()) }));
struct MyResolver {
trust_dns: TokioAsyncResolver,

View File

@ -2,7 +2,7 @@
## Unreleased - 2023-xx-xx
- Minimum supported Rust version (MSRV) is now 1.60.
- Minimum supported Rust version (MSRV) is now 1.65.
## 0.1.0 - 2020-01-15

View File

@ -9,8 +9,8 @@ repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-tracing"
categories = ["network-programming", "asynchronous"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.60"
edition.workspace = true
rust-version.workspace = true
[dependencies]
actix-service = "2"

View File

@ -118,9 +118,11 @@ where
#[cfg(test)]
mod test {
use std::cell::RefCell;
use std::collections::{BTreeMap, BTreeSet};
use std::sync::{Arc, RwLock};
use std::{
cell::RefCell,
collections::{BTreeMap, BTreeSet},
sync::{Arc, RwLock},
};
use actix_service::{fn_factory, fn_service};
use slab::Slab;

View File

@ -2,7 +2,7 @@
## Unreleased - 2023-xx-xx
- Minimum supported Rust version (MSRV) is now 1.60.
- Minimum supported Rust version (MSRV) is now 1.65.
## 3.0.1 - 2022-10-21

View File

@ -10,8 +10,8 @@ keywords = ["network", "framework", "async", "futures"]
categories = ["network-programming", "asynchronous"]
repository = "https://github.com/actix/actix-net"
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.60"
edition.workspace = true
rust-version.workspace = true
[dependencies]
pin-project-lite = "0.2"

View File

@ -4,6 +4,8 @@ mod either;
mod poll_fn;
mod ready;
pub use self::either::Either;
pub use self::poll_fn::{poll_fn, PollFn};
pub use self::ready::{err, ok, ready, Ready};
pub use self::{
either::Either,
poll_fn::{poll_fn, PollFn},
ready::{err, ok, ready, Ready},
};

View File

@ -11,8 +11,8 @@ categories = ["no-std", "web-programming"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git"
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.60"
edition.workspace = true
rust-version.workspace = true
[dependencies]
bytes = { version = "1.2", default-features = false }

View File

@ -253,8 +253,10 @@ impl fmt::Display for ByteString {
mod serde {
use alloc::string::String;
use serde::de::{Deserialize, Deserializer};
use serde::ser::{Serialize, Serializer};
use serde::{
de::{Deserialize, Deserializer},
ser::{Serialize, Serializer},
};
use super::ByteString;

View File

@ -2,7 +2,7 @@
## Unreleased - 2023-xx-xx
- Minimum supported Rust version (MSRV) is now 1.60.
- Minimum supported Rust version (MSRV) is now 1.65.
## 0.1.3 - 2022-05-03

View File

@ -9,8 +9,8 @@ authors = [
repository = "https://github.com/actix/actix-net.git"
keywords = ["channel", "local", "futures"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.60"
edition.workspace = true
rust-version.workspace = true
[dependencies]
futures-core = "0.3.17"

View File

@ -2,7 +2,7 @@
## Unreleased - 2023-xx-xx
- Minimum supported Rust version (MSRV) is now 1.60.
- Minimum supported Rust version (MSRV) is now 1.65.
## 0.1.3 - 2022-05-03

View File

@ -10,7 +10,7 @@ repository = "https://github.com/actix/actix-net.git"
keywords = ["waker", "local", "futures", "no-std"]
categories = ["asynchronous", "no-std"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.60"
edition.workspace = true
rust-version.workspace = true
[dependencies]

View File

@ -1,2 +0,0 @@
max_width = 96
group_imports = "StdExternalCrate"