tower/limit/concurrency/
future.rs1use pin_project_lite::pin_project;
5use std::{
6 future::Future,
7 pin::Pin,
8 task::{Context, Poll},
9};
10use tokio::sync::OwnedSemaphorePermit;
11
12pin_project! {
13 #[derive(Debug)]
17 pub struct ResponseFuture<T> {
18 #[pin]
19 inner: T,
20 _permit: OwnedSemaphorePermit,
22 }
23}
24
25impl<T> ResponseFuture<T> {
26 pub(crate) fn new(inner: T, _permit: OwnedSemaphorePermit) -> ResponseFuture<T> {
27 ResponseFuture { inner, _permit }
28 }
29}
30
31impl<F, T, E> Future for ResponseFuture<F>
32where
33 F: Future<Output = Result<T, E>>,
34{
35 type Output = Result<T, E>;
36
37 fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
38 self.project().inner.poll(cx)
39 }
40}