1
0
mirror of https://github.com/actix/examples synced 2025-06-26 17:17:42 +02:00

chore: update pin-project

This commit is contained in:
Rob Ede
2024-07-07 01:42:16 +01:00
parent ea07cc2370
commit 03879899a5
13 changed files with 43 additions and 67 deletions

View File

@ -12,4 +12,4 @@ actix-web-lab.workspace = true
env_logger.workspace = true
futures-util.workspace = true
log.workspace = true
pin-project = "1"
pin-project-lite.workspace = true

View File

@ -11,6 +11,7 @@ use actix_web::{
web::{Bytes, BytesMut},
Error,
};
use pin_project_lite::pin_project;
pub struct Logging;
@ -53,15 +54,16 @@ where
}
}
#[pin_project::pin_project]
pub struct WrapperStream<S, B>
where
B: MessageBody,
S: Service<ServiceRequest>,
{
#[pin]
fut: S::Future,
_t: PhantomData<(B,)>,
pin_project! {
pub struct WrapperStream<S, B>
where
B: MessageBody,
S: Service<ServiceRequest>,
{
#[pin]
fut: S::Future,
_t: PhantomData<(B,)>,
}
}
impl<S, B> Future for WrapperStream<S, B>
@ -83,17 +85,17 @@ where
}
}
#[pin_project::pin_project(PinnedDrop)]
pub struct BodyLogger<B> {
#[pin]
body: B,
body_accum: BytesMut,
}
pin_project! {
pub struct BodyLogger<B> {
#[pin]
body: B,
body_accum: BytesMut,
}
#[pin_project::pinned_drop]
impl<B> PinnedDrop for BodyLogger<B> {
fn drop(self: Pin<&mut Self>) {
println!("response body: {:?}", self.body_accum);
impl<B> PinnedDrop for BodyLogger<B> {
fn drop(this: Pin<&mut Self>) {
println!("response body: {:?}", this.body_accum);
}
}
}