Files

40 lines
1.0 KiB
Rust

//! Copyright (c) 2022-2026 GitDataAi All rights reserved.
pub mod advertise_refs;
pub mod fsck;
pub mod index_pack;
pub mod list_packfiles;
pub mod pack_objects;
pub mod receive_pack;
pub mod upload_pack;
/// A wrapper around ReceiverStream that cancels a token when dropped.
/// Used to properly clean up child processes when clients disconnect.
pub struct CancellableReceiverStream<T> {
inner: tokio_stream::wrappers::ReceiverStream<T>,
_cancel_guard: tokio_util::sync::DropGuard,
}
impl<T> CancellableReceiverStream<T> {
pub fn new(
inner: tokio_stream::wrappers::ReceiverStream<T>,
cancel_guard: tokio_util::sync::DropGuard,
) -> Self {
Self {
inner,
_cancel_guard: cancel_guard,
}
}
}
impl<T> tokio_stream::Stream for CancellableReceiverStream<T> {
type Item = T;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
std::pin::Pin::new(&mut self.inner).poll_next(cx)
}
}