mirror of
https://github.com/fafhrd91/actix-net
synced 2025-02-20 07:40:33 +01:00
fmt with import grouping
This commit is contained in:
parent
855e3f96fe
commit
dc67ba770d
@ -16,10 +16,10 @@ mod bcodec;
|
|||||||
mod framed;
|
mod framed;
|
||||||
mod lines;
|
mod lines;
|
||||||
|
|
||||||
pub use self::bcodec::BytesCodec;
|
|
||||||
pub use self::framed::{Framed, FramedParts};
|
|
||||||
pub use self::lines::LinesCodec;
|
|
||||||
|
|
||||||
pub use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
pub use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
||||||
pub use tokio_util::codec::{Decoder, Encoder};
|
pub use tokio_util::codec::{Decoder, Encoder};
|
||||||
pub use tokio_util::io::poll_read_buf;
|
pub use tokio_util::io::poll_read_buf;
|
||||||
|
|
||||||
|
pub use self::bcodec::BytesCodec;
|
||||||
|
pub use self::framed::{Framed, FramedParts};
|
||||||
|
pub use self::lines::LinesCodec;
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
|
use std::{
|
||||||
|
collections::VecDeque,
|
||||||
|
io::{self, Write},
|
||||||
|
pin::Pin,
|
||||||
|
task::{
|
||||||
|
Context,
|
||||||
|
Poll::{self, Pending, Ready},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
use actix_codec::*;
|
use actix_codec::*;
|
||||||
use bytes::Buf;
|
use bytes::{Buf as _, BufMut as _, BytesMut};
|
||||||
use bytes::{BufMut, BytesMut};
|
|
||||||
use futures_sink::Sink;
|
use futures_sink::Sink;
|
||||||
use std::collections::VecDeque;
|
|
||||||
use std::io::{self, Write};
|
|
||||||
use std::pin::Pin;
|
|
||||||
use std::task::Poll::{Pending, Ready};
|
|
||||||
use std::task::{Context, Poll};
|
|
||||||
use tokio_test::{assert_ready, task};
|
use tokio_test::{assert_ready, task};
|
||||||
|
|
||||||
macro_rules! bilateral {
|
macro_rules! bilateral {
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
use hyper::service::{make_service_fn, service_fn};
|
use std::{convert::Infallible, net::SocketAddr};
|
||||||
use hyper::{Body, Request, Response, Server};
|
|
||||||
use std::convert::Infallible;
|
use hyper::{
|
||||||
use std::net::SocketAddr;
|
service::{make_service_fn, service_fn},
|
||||||
|
Body, Request, Response, Server,
|
||||||
|
};
|
||||||
|
|
||||||
async fn handle(_req: Request<Body>) -> Result<Response<Body>, Infallible> {
|
async fn handle(_req: Request<Body>) -> Result<Response<Body>, Infallible> {
|
||||||
Ok(Response::new(Body::from("Hello World")))
|
Ok(Response::new(Body::from("Hello World")))
|
||||||
|
@ -51,13 +51,10 @@ compile_error!("io_uring is a linux only feature.");
|
|||||||
|
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
||||||
use tokio::task::JoinHandle;
|
|
||||||
|
|
||||||
// Cannot define a main macro when compiled into test harness.
|
// Cannot define a main macro when compiled into test harness.
|
||||||
// Workaround for https://github.com/rust-lang/rust/issues/62127.
|
// Workaround for https://github.com/rust-lang/rust/issues/62127.
|
||||||
#[cfg(all(feature = "macros", not(test)))]
|
#[cfg(all(feature = "macros", not(test)))]
|
||||||
pub use actix_macros::main;
|
pub use actix_macros::main;
|
||||||
|
|
||||||
#[cfg(feature = "macros")]
|
#[cfg(feature = "macros")]
|
||||||
pub use actix_macros::test;
|
pub use actix_macros::test;
|
||||||
|
|
||||||
@ -65,12 +62,13 @@ mod arbiter;
|
|||||||
mod runtime;
|
mod runtime;
|
||||||
mod system;
|
mod system;
|
||||||
|
|
||||||
|
pub use tokio::pin;
|
||||||
|
use tokio::task::JoinHandle;
|
||||||
|
|
||||||
pub use self::arbiter::{Arbiter, ArbiterHandle};
|
pub use self::arbiter::{Arbiter, ArbiterHandle};
|
||||||
pub use self::runtime::Runtime;
|
pub use self::runtime::Runtime;
|
||||||
pub use self::system::{System, SystemRunner};
|
pub use self::system::{System, SystemRunner};
|
||||||
|
|
||||||
pub use tokio::pin;
|
|
||||||
|
|
||||||
pub mod signal {
|
pub mod signal {
|
||||||
//! Asynchronous signal handling (Tokio re-exports).
|
//! Asynchronous signal handling (Tokio re-exports).
|
||||||
|
|
||||||
@ -95,7 +93,6 @@ pub mod net {
|
|||||||
use tokio::io::{AsyncRead, AsyncWrite, Interest};
|
use tokio::io::{AsyncRead, AsyncWrite, Interest};
|
||||||
pub use tokio::net::UdpSocket;
|
pub use tokio::net::UdpSocket;
|
||||||
pub use tokio::net::{TcpListener, TcpSocket, TcpStream};
|
pub use tokio::net::{TcpListener, TcpSocket, TcpStream};
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub use tokio::net::{UnixDatagram, UnixListener, UnixStream};
|
pub use tokio::net::{UnixDatagram, UnixListener, UnixStream};
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use actix_rt::{task::JoinError, Arbiter, System};
|
use actix_rt::{task::JoinError, Arbiter, System};
|
||||||
|
|
||||||
#[cfg(not(feature = "io-uring"))]
|
#[cfg(not(feature = "io-uring"))]
|
||||||
use {
|
use {
|
||||||
std::{sync::mpsc::channel, thread},
|
std::{sync::mpsc::channel, thread},
|
||||||
|
@ -63,10 +63,10 @@ impl<T> Future for JoinAll<T> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
|
||||||
|
|
||||||
use actix_utils::future::ready;
|
use actix_utils::future::ready;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_join_all() {
|
async fn test_join_all() {
|
||||||
let futs = vec![ready(Ok(1)), ready(Err(3)), ready(Ok(9))];
|
let futs = vec![ready(Ok(1)), ready(Err(3)), ready(Ok(9))];
|
||||||
|
@ -22,10 +22,9 @@ pub use self::builder::ServerBuilder;
|
|||||||
pub use self::handle::ServerHandle;
|
pub use self::handle::ServerHandle;
|
||||||
pub use self::server::Server;
|
pub use self::server::Server;
|
||||||
pub use self::service::ServerServiceFactory;
|
pub use self::service::ServerServiceFactory;
|
||||||
pub use self::test_server::TestServer;
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use self::socket::FromStream;
|
pub use self::socket::FromStream;
|
||||||
|
pub use self::test_server::TestServer;
|
||||||
|
|
||||||
/// Start server building process
|
/// Start server building process
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
@ -6,7 +6,6 @@ use std::{fmt, io};
|
|||||||
use actix_rt::net::TcpStream;
|
use actix_rt::net::TcpStream;
|
||||||
pub(crate) use mio::net::TcpListener as MioTcpListener;
|
pub(crate) use mio::net::TcpListener as MioTcpListener;
|
||||||
use mio::{event::Source, Interest, Registry, Token};
|
use mio::{event::Source, Interest, Registry, Token};
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub(crate) use {
|
pub(crate) use {
|
||||||
mio::net::UnixListener as MioUnixListener,
|
mio::net::UnixListener as MioUnixListener,
|
||||||
|
@ -394,9 +394,10 @@ mod tests {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_auto_impl_send() {
|
async fn test_auto_impl_send() {
|
||||||
use crate::{map_config, ServiceExt, ServiceFactoryExt};
|
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
|
|
||||||
|
use crate::{map_config, ServiceExt, ServiceFactoryExt};
|
||||||
|
|
||||||
let srv_1 = fn_service(|_: Rc<u8>| ok::<_, Rc<u8>>(Rc::new(0u8)));
|
let srv_1 = fn_service(|_: Rc<u8>| ok::<_, Rc<u8>>(Rc::new(0u8)));
|
||||||
|
|
||||||
let fac_1 = fn_factory_with_config(|_: Rc<u8>| {
|
let fac_1 = fn_factory_with_config(|_: Rc<u8>| {
|
||||||
|
@ -38,10 +38,9 @@ pub use self::apply_cfg::{apply_cfg, apply_cfg_factory};
|
|||||||
pub use self::ext::{ServiceExt, ServiceFactoryExt, TransformExt};
|
pub use self::ext::{ServiceExt, ServiceFactoryExt, TransformExt};
|
||||||
pub use self::fn_service::{fn_factory, fn_factory_with_config, fn_service};
|
pub use self::fn_service::{fn_factory, fn_factory_with_config, fn_service};
|
||||||
pub use self::map_config::{map_config, unit_config};
|
pub use self::map_config::{map_config, unit_config};
|
||||||
pub use self::transform::{apply, ApplyTransform, Transform};
|
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use self::ready::{err, ok, ready, Ready};
|
use self::ready::{err, ok, ready, Ready};
|
||||||
|
pub use self::transform::{apply, ApplyTransform, Transform};
|
||||||
|
|
||||||
/// An asynchronous operation from `Request` to a `Response`.
|
/// An asynchronous operation from `Request` to a `Response`.
|
||||||
///
|
///
|
||||||
|
@ -15,8 +15,9 @@
|
|||||||
//! http --verify=false https://127.0.0.1:8443
|
//! http --verify=false https://127.0.0.1:8443
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
// this use only exists because of how we have organised the crate
|
#[rustfmt::skip]
|
||||||
// it is not necessary for your actual code
|
// this `use` is only exists because of how we have organised the crate
|
||||||
|
// it is not necessary for your actual code; you should import from `rustls` directly
|
||||||
use tokio_rustls::rustls;
|
use tokio_rustls::rustls;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -20,7 +20,6 @@ pub mod reexports {
|
|||||||
//! Re-exports from `native-tls` and `tokio-native-tls` that are useful for connectors.
|
//! 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::native_tls::TlsConnector;
|
||||||
|
|
||||||
pub use tokio_native_tls::TlsStream as AsyncTlsStream;
|
pub use tokio_native_tls::TlsStream as AsyncTlsStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ pub mod reexports {
|
|||||||
pub use openssl::ssl::{
|
pub use openssl::ssl::{
|
||||||
Error, HandshakeError, SslConnector, SslConnectorBuilder, SslMethod,
|
Error, HandshakeError, SslConnector, SslConnectorBuilder, SslMethod,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use tokio_openssl::SslStream as AsyncSslStream;
|
pub use tokio_openssl::SslStream as AsyncSslStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,10 +26,8 @@ use crate::connect::{Connection, Host};
|
|||||||
pub mod reexports {
|
pub mod reexports {
|
||||||
//! Re-exports from `rustls` and `webpki_roots` that are useful for connectors.
|
//! Re-exports from `rustls` and `webpki_roots` that are useful for connectors.
|
||||||
|
|
||||||
pub use tokio_rustls::rustls::ClientConfig;
|
|
||||||
|
|
||||||
pub use tokio_rustls::client::TlsStream as AsyncTlsStream;
|
pub use tokio_rustls::client::TlsStream as AsyncTlsStream;
|
||||||
|
pub use tokio_rustls::rustls::ClientConfig;
|
||||||
pub use webpki_roots::TLS_SERVER_ROOTS;
|
pub use webpki_roots::TLS_SERVER_ROOTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,13 +51,13 @@ fn openssl_acceptor(cert: String, key: String) -> tls_openssl::ssl::SslAcceptor
|
|||||||
mod danger {
|
mod danger {
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
use tokio_rustls::rustls::{
|
use tokio_rustls::rustls::{
|
||||||
self,
|
self,
|
||||||
client::{ServerCertVerified, ServerCertVerifier},
|
client::{ServerCertVerified, ServerCertVerifier},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
pub struct NoCertificateVerification;
|
pub struct NoCertificateVerification;
|
||||||
|
|
||||||
impl ServerCertVerifier for NoCertificateVerification {
|
impl ServerCertVerifier for NoCertificateVerification {
|
||||||
|
@ -9,11 +9,10 @@ use actix_codec::{BytesCodec, Framed};
|
|||||||
use actix_rt::net::TcpStream;
|
use actix_rt::net::TcpStream;
|
||||||
use actix_server::TestServer;
|
use actix_server::TestServer;
|
||||||
use actix_service::{fn_service, Service, ServiceFactory};
|
use actix_service::{fn_service, Service, ServiceFactory};
|
||||||
|
use actix_tls::connect::{ConnectError, ConnectInfo, Connection, Connector, Host};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures_util::sink::SinkExt;
|
use futures_util::sink::SinkExt;
|
||||||
|
|
||||||
use actix_tls::connect::{ConnectError, ConnectInfo, Connection, Connector, Host};
|
|
||||||
|
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_string() {
|
async fn test_string() {
|
||||||
|
@ -8,11 +8,10 @@ use std::{
|
|||||||
use actix_rt::net::TcpStream;
|
use actix_rt::net::TcpStream;
|
||||||
use actix_server::TestServer;
|
use actix_server::TestServer;
|
||||||
use actix_service::{fn_service, Service, ServiceFactory};
|
use actix_service::{fn_service, Service, ServiceFactory};
|
||||||
use futures_core::future::LocalBoxFuture;
|
|
||||||
|
|
||||||
use actix_tls::connect::{
|
use actix_tls::connect::{
|
||||||
ConnectError, ConnectInfo, Connection, Connector, Host, Resolve, Resolver,
|
ConnectError, ConnectInfo, Connection, Connector, Host, Resolve, Resolver,
|
||||||
};
|
};
|
||||||
|
use futures_core::future::LocalBoxFuture;
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn custom_resolver() {
|
async fn custom_resolver() {
|
||||||
|
@ -118,8 +118,6 @@ where
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::{BTreeMap, BTreeSet};
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
@ -128,6 +126,8 @@ mod test {
|
|||||||
use slab::Slab;
|
use slab::Slab;
|
||||||
use tracing::{span, Event, Level, Metadata, Subscriber};
|
use tracing::{span, Event, Level, Metadata, Subscriber};
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
thread_local! {
|
thread_local! {
|
||||||
static SPAN: RefCell<Vec<span::Id>> = RefCell::new(Vec::new());
|
static SPAN: RefCell<Vec<span::Id>> = RefCell::new(Vec::new());
|
||||||
}
|
}
|
||||||
|
@ -219,11 +219,11 @@ mod serde {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod serde_impl_tests {
|
mod serde_impl_tests {
|
||||||
use super::*;
|
|
||||||
|
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
use static_assertions::assert_impl_all;
|
use static_assertions::assert_impl_all;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
assert_impl_all!(ByteString: Serialize, DeserializeOwned);
|
assert_impl_all!(ByteString: Serialize, DeserializeOwned);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
max_width = 96
|
max_width = 96
|
||||||
reorder_imports = true
|
group_imports = "StdExternalCrate"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user