From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup v3 2/4] remove tools/async_io.rs
Date: Wed, 29 Sep 2021 09:04:18 +0200 [thread overview]
Message-ID: <20210929070420.617226-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210929070420.617226-1-d.csapak@proxmox.com>
nothing from here is used anymore, so remove it
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/tools/async_io.rs | 83 -------------------------------------------
src/tools/mod.rs | 1 -
2 files changed, 84 deletions(-)
delete mode 100644 src/tools/async_io.rs
diff --git a/src/tools/async_io.rs b/src/tools/async_io.rs
deleted file mode 100644
index 66d38094..00000000
--- a/src/tools/async_io.rs
+++ /dev/null
@@ -1,83 +0,0 @@
-//! AsyncRead/AsyncWrite utilities.
-
-use std::os::unix::io::{AsRawFd, RawFd};
-use std::pin::Pin;
-use std::task::{Context, Poll};
-
-use futures::stream::{Stream, TryStream};
-use futures::ready;
-use tokio::io::{AsyncRead, AsyncWrite};
-use tokio::net::TcpListener;
-
-
-/// Tokio's `Incoming` now is a reference type and hyper's `AddrIncoming` misses some standard
-/// stuff like `AsRawFd`, so here's something implementing hyper's `Accept` from a `TcpListener`
-pub struct StaticIncoming(TcpListener);
-
-impl From<TcpListener> for StaticIncoming {
- fn from(inner: TcpListener) -> Self {
- Self(inner)
- }
-}
-
-impl AsRawFd for StaticIncoming {
- fn as_raw_fd(&self) -> RawFd {
- self.0.as_raw_fd()
- }
-}
-
-impl hyper::server::accept::Accept for StaticIncoming {
- type Conn = tokio::net::TcpStream;
- type Error = std::io::Error;
-
- fn poll_accept(
- self: Pin<&mut Self>,
- cx: &mut Context,
- ) -> Poll<Option<Result<Self::Conn, Self::Error>>> {
- let this = self.get_mut();
- loop {
- match ready!(this.0.poll_accept(cx)) {
- Ok((conn, _addr)) => return Poll::Ready(Some(Ok(conn))),
- Err(err) => {
- eprintln!("error accepting connection: {}", err);
- continue;
- }
- }
- }
- }
-}
-
-/// We also implement TryStream for this, as tokio doesn't do this anymore either and we want to be
-/// able to map connections to then add eg. ssl to them. This support code makes the changes
-/// required for hyper 0.13 a bit less annoying to read.
-impl Stream for StaticIncoming {
- type Item = std::io::Result<(tokio::net::TcpStream, std::net::SocketAddr)>;
-
- fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
- match self.get_mut().0.poll_accept(cx) {
- Poll::Pending => Poll::Pending,
- Poll::Ready(result) => Poll::Ready(Some(result)),
- }
- }
-}
-
-/// Implement hyper's `Accept` for any `TryStream` of sockets:
-pub struct HyperAccept<T>(pub T);
-
-
-impl<T, I> hyper::server::accept::Accept for HyperAccept<T>
-where
- T: TryStream<Ok = I> + Unpin,
- I: AsyncRead + AsyncWrite,
-{
- type Conn = I;
- type Error = T::Error;
-
- fn poll_accept(
- self: Pin<&mut Self>,
- cx: &mut Context,
- ) -> Poll<Option<Result<Self::Conn, Self::Error>>> {
- let this = Pin::new(&mut self.get_mut().0);
- this.try_poll_next(cx)
- }
-}
diff --git a/src/tools/mod.rs b/src/tools/mod.rs
index 5dc129f0..d8ed7275 100644
--- a/src/tools/mod.rs
+++ b/src/tools/mod.rs
@@ -13,7 +13,6 @@ use proxmox_http::{
};
pub mod apt;
-pub mod async_io;
pub mod config;
pub mod disks;
--
2.30.2
next prev parent reply other threads:[~2021-09-29 7:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-29 7:04 [pbs-devel] [PATCH proxmox-backup v3 0/3] add rest_server example Dominik Csapak
2021-09-29 7:04 ` [pbs-devel] [PATCH proxmox-backup v3 1/4] rest-server: use hypers AddrIncoming for proxmox-backup-api Dominik Csapak
2021-09-29 7:04 ` Dominik Csapak [this message]
2021-09-29 7:04 ` [pbs-devel] [PATCH proxmox-backup v3 3/4] examples: add example for a simple rest server with a small api Dominik Csapak
2021-09-29 7:04 ` [pbs-devel] [PATCH proxmox-backup v3 4/4] fixup! rest-server: use hypers AddrIncoming for proxmox-backup-api Dominik Csapak
2021-09-29 7:07 ` Dominik Csapak
2021-09-29 7:49 ` [pbs-devel] applied-series: [PATCH proxmox-backup v3 0/3] add rest_server example Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210929070420.617226-3-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox