mirror of https://github.com/fafhrd91/actix-net
				
				
				
			Compare commits
	
		
			2 Commits
		
	
	
		
			6f5b81d2a0
			...
			70f0008f42
		
	
	| Author | SHA1 | Date | 
|---|---|---|
| 
							
							
								 | 
						70f0008f42 | |
| 
							
							
								 | 
						12df4d7027 | 
| 
						 | 
					@ -63,13 +63,12 @@ dependencies = [
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[package]]
 | 
					[[package]]
 | 
				
			||||||
name = "actix-service"
 | 
					name = "actix-service"
 | 
				
			||||||
version = "2.0.2"
 | 
					version = "2.0.3"
 | 
				
			||||||
dependencies = [
 | 
					dependencies = [
 | 
				
			||||||
 "actix-rt",
 | 
					 "actix-rt",
 | 
				
			||||||
 "actix-utils",
 | 
					 "actix-utils",
 | 
				
			||||||
 "futures-core",
 | 
					 "futures-core",
 | 
				
			||||||
 "futures-util",
 | 
					 "futures-util",
 | 
				
			||||||
 "paste",
 | 
					 | 
				
			||||||
 "pin-project-lite",
 | 
					 "pin-project-lite",
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,6 +2,8 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Unreleased
 | 
					## Unreleased
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## 2.0.3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Minimum supported Rust version (MSRV) is now 1.71.
 | 
					- Minimum supported Rust version (MSRV) is now 1.71.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## 2.0.2
 | 
					## 2.0.2
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
[package]
 | 
					[package]
 | 
				
			||||||
name = "actix-service"
 | 
					name = "actix-service"
 | 
				
			||||||
version = "2.0.2"
 | 
					version = "2.0.3"
 | 
				
			||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>", "Rob Ede <robjtede@icloud.com>"]
 | 
					authors = ["Nikolay Kim <fafhrd91@gmail.com>", "Rob Ede <robjtede@icloud.com>"]
 | 
				
			||||||
description = "Service trait and combinators for representing asynchronous request/response operations."
 | 
					description = "Service trait and combinators for representing asynchronous request/response operations."
 | 
				
			||||||
keywords = ["network", "framework", "async", "futures", "service"]
 | 
					keywords = ["network", "framework", "async", "futures", "service"]
 | 
				
			||||||
| 
						 | 
					@ -12,7 +12,6 @@ rust-version.workspace = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[dependencies]
 | 
					[dependencies]
 | 
				
			||||||
futures-core = { version = "0.3.17", default-features = false }
 | 
					futures-core = { version = "0.3.17", default-features = false }
 | 
				
			||||||
paste = "1"
 | 
					 | 
				
			||||||
pin-project-lite = "0.2"
 | 
					pin-project-lite = "0.2"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[dev-dependencies]
 | 
					[dev-dependencies]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,10 +3,10 @@
 | 
				
			||||||
> Service trait and combinators for representing asynchronous request/response operations.
 | 
					> Service trait and combinators for representing asynchronous request/response operations.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[](https://crates.io/crates/actix-service)
 | 
					[](https://crates.io/crates/actix-service)
 | 
				
			||||||
[](https://docs.rs/actix-service/2.0.2)
 | 
					[](https://docs.rs/actix-service/2.0.3)
 | 
				
			||||||
[](https://blog.rust-lang.org/2020/03/12/Rust-1.46.html)
 | 
					[](https://blog.rust-lang.org/2020/03/12/Rust-1.46.html)
 | 
				
			||||||

 | 
					
 | 
				
			||||||
[](https://deps.rs/crate/actix-service/2.0.2)
 | 
					[](https://deps.rs/crate/actix-service/2.0.3)
 | 
				
			||||||

 | 
					
 | 
				
			||||||
[](https://discord.gg/NWpN5mmg3x)
 | 
					[](https://discord.gg/NWpN5mmg3x)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,36 +3,38 @@
 | 
				
			||||||
use alloc::{boxed::Box, rc::Rc};
 | 
					use alloc::{boxed::Box, rc::Rc};
 | 
				
			||||||
use core::{future::Future, pin::Pin};
 | 
					use core::{future::Future, pin::Pin};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use paste::paste;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
use crate::{Service, ServiceFactory};
 | 
					use crate::{Service, ServiceFactory};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// A boxed future with no send bound or lifetime parameters.
 | 
					/// A boxed future with no send bound or lifetime parameters.
 | 
				
			||||||
pub type BoxFuture<T> = Pin<Box<dyn Future<Output = T>>>;
 | 
					pub type BoxFuture<T> = Pin<Box<dyn Future<Output = T>>>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
macro_rules! service_object {
 | 
					/// Type alias for service trait object using [`Box`].
 | 
				
			||||||
    ($name: ident, $type: tt, $fn_name: ident) => {
 | 
					pub type BoxService<Req, Res, Err> =
 | 
				
			||||||
        paste! {
 | 
					    Box<dyn Service<Req, Response = Res, Error = Err, Future = BoxFuture<Result<Res, Err>>>>;
 | 
				
			||||||
            #[doc = "Type alias for service trait object using `" $type "`."]
 | 
					 | 
				
			||||||
            pub type $name<Req, Res, Err> = $type<
 | 
					 | 
				
			||||||
                dyn Service<Req, Response = Res, Error = Err, Future = BoxFuture<Result<Res, Err>>>,
 | 
					 | 
				
			||||||
            >;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #[doc = "Wraps service as a trait object using [`" $name "`]."]
 | 
					/// Wraps service as a trait object using [`BoxService`].
 | 
				
			||||||
            pub fn $fn_name<S, Req>(service: S) -> $name<Req, S::Response, S::Error>
 | 
					pub fn service<S, Req>(service: S) -> BoxService<Req, S::Response, S::Error>
 | 
				
			||||||
            where
 | 
					where
 | 
				
			||||||
                S: Service<Req> + 'static,
 | 
					    S: Service<Req> + 'static,
 | 
				
			||||||
                Req: 'static,
 | 
					    Req: 'static,
 | 
				
			||||||
                S::Future: 'static,
 | 
					    S::Future: 'static,
 | 
				
			||||||
            {
 | 
					{
 | 
				
			||||||
                $type::new(ServiceWrapper::new(service))
 | 
					    Box::new(ServiceWrapper::new(service))
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
service_object!(BoxService, Box, service);
 | 
					/// Type alias for service trait object using [`Rc`].
 | 
				
			||||||
service_object!(RcService, Rc, rc_service);
 | 
					pub type RcService<Req, Res, Err> =
 | 
				
			||||||
 | 
					    Rc<dyn Service<Req, Response = Res, Error = Err, Future = BoxFuture<Result<Res, Err>>>>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/// Wraps service as a trait object using [`RcService`].
 | 
				
			||||||
 | 
					pub fn rc_service<S, Req>(service: S) -> RcService<Req, S::Response, S::Error>
 | 
				
			||||||
 | 
					where
 | 
				
			||||||
 | 
					    S: Service<Req> + 'static,
 | 
				
			||||||
 | 
					    Req: 'static,
 | 
				
			||||||
 | 
					    S::Future: 'static,
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    Rc::new(ServiceWrapper::new(service))
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct ServiceWrapper<S> {
 | 
					struct ServiceWrapper<S> {
 | 
				
			||||||
    inner: S,
 | 
					    inner: S,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue