mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-25 09:59:21 +02:00
Optionally support tokio-uds's UnixStream as IoStream (#472)
This commit is contained in:
@ -1287,6 +1287,10 @@ impl Connection {
|
||||
}
|
||||
|
||||
/// Create a new connection from an IO Stream
|
||||
///
|
||||
/// The stream can be a `UnixStream` if the Unix-only "uds" feature is enabled.
|
||||
///
|
||||
/// See also `ClientRequestBuilder::with_connection()`.
|
||||
pub fn from_stream<T: IoStream + Send>(io: T) -> Connection {
|
||||
Connection::new(Key::empty(), None, Box::new(io))
|
||||
}
|
||||
|
@ -66,6 +66,8 @@
|
||||
//! * `tls` - enables ssl support via `native-tls` crate
|
||||
//! * `alpn` - enables ssl support via `openssl` crate, require for `http/2`
|
||||
//! support
|
||||
//! * `uds` - enables support for making client requests via Unix Domain Sockets.
|
||||
//! Unix only. Not necessary for *serving* requests.
|
||||
//! * `session` - enables session support, includes `ring` crate as
|
||||
//! dependency
|
||||
//! * `brotli` - enables `brotli` compression support, requires `c`
|
||||
@ -120,6 +122,8 @@ extern crate tokio_io;
|
||||
extern crate tokio_reactor;
|
||||
extern crate tokio_tcp;
|
||||
extern crate tokio_timer;
|
||||
#[cfg(all(unix, feature = "uds"))]
|
||||
extern crate tokio_uds;
|
||||
extern crate url;
|
||||
#[macro_use]
|
||||
extern crate serde;
|
||||
|
@ -421,6 +421,24 @@ pub trait IoStream: AsyncRead + AsyncWrite + 'static {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(unix, feature = "uds"))]
|
||||
impl IoStream for ::tokio_uds::UnixStream {
|
||||
#[inline]
|
||||
fn shutdown(&mut self, how: Shutdown) -> io::Result<()> {
|
||||
::tokio_uds::UnixStream::shutdown(self, how)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_nodelay(&mut self, _nodelay: bool) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_linger(&mut self, _dur: Option<time::Duration>) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl IoStream for TcpStream {
|
||||
#[inline]
|
||||
fn shutdown(&mut self, how: Shutdown) -> io::Result<()> {
|
||||
|
Reference in New Issue
Block a user