1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-01-19 00:31:50 +01:00
This commit is contained in:
Rob Ede 2021-10-28 20:59:44 +01:00
parent 75a877b631
commit e49fedbfe7
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933

View File

@ -1,5 +1,4 @@
use std::sync::mpsc; use std::{fmt, net, sync::mpsc, thread};
use std::{fmt, net, thread};
use actix_rt::{net::TcpStream, System}; use actix_rt::{net::TcpStream, System};
use actix_service::ServiceFactory; use actix_service::ServiceFactory;
@ -28,9 +27,10 @@ use crate::{Server, ServerBuilder};
/// println!("SOCKET: {:?}", srv.connect()); /// println!("SOCKET: {:?}", srv.connect());
/// } /// }
/// ``` /// ```
#[non_exhaustive]
pub struct TestServer; pub struct TestServer;
/// Test server runtime /// Test server runtime.
pub struct TestServerRuntime { pub struct TestServerRuntime {
addr: net::SocketAddr, addr: net::SocketAddr,
host: String, host: String,
@ -39,7 +39,7 @@ pub struct TestServerRuntime {
} }
impl TestServer { impl TestServer {
/// Start new server with server builder. /// Start new server using server builder.
pub fn start<F>(mut factory: F) -> TestServerRuntime pub fn start<F>(mut factory: F) -> TestServerRuntime
where where
F: FnMut(ServerBuilder) -> ServerBuilder + Send + 'static, F: FnMut(ServerBuilder) -> ServerBuilder + Send + 'static,
@ -64,7 +64,7 @@ impl TestServer {
} }
} }
/// Start new test server with application factory. /// Start new test server with default settings using application factory.
pub fn with<F, InitErr>(factory: F) -> TestServerRuntime pub fn with<F, InitErr>(factory: F) -> TestServerRuntime
where where
F: ServiceFactory<TcpStream, Config = (), InitError = InitErr> + Send + Clone + 'static, F: ServiceFactory<TcpStream, Config = (), InitError = InitErr> + Send + Clone + 'static,