File tree Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ tracing-log = "0.2"
5858serde_derive = " 1.0"
5959handlebars = " 6.0"
6060tokio = { version = " 1.0" , features = [" macros" , " rt-multi-thread" ] }
61- tokio-stream = { version = " 0.1.1" , features = [ " net " ] }
61+ tokio-stream = " 0.1.1"
6262
6363[features ]
6464default = []
@@ -151,6 +151,10 @@ required-features = ["server"]
151151name = " tracing"
152152required-features = [" server" ]
153153
154+ [[example ]]
155+ name = " unix_socket"
156+ required-features = [" server" ]
157+
154158[[example ]]
155159name = " websockets"
156160required-features = [" websocket" , " server" ]
Original file line number Diff line number Diff line change 1- /*
21#![ deny( warnings) ]
32
43#[ cfg( unix) ]
54#[ tokio:: main]
65async fn main ( ) {
76 use tokio:: net:: UnixListener ;
8- use tokio_stream::wrappers::UnixListenerStream;
97
108 pretty_env_logger:: init ( ) ;
119
1210 let listener = UnixListener :: bind ( "/tmp/warp.sock" ) . unwrap ( ) ;
13- let incoming = UnixListenerStream::new(listener);
1411 warp:: serve ( warp:: fs:: dir ( "examples/dir" ) )
15- .run_incoming(incoming)
12+ . incoming ( listener)
13+ . run ( )
1614 . await ;
1715}
1816
@@ -21,5 +19,3 @@ async fn main() {
2119async fn main ( ) {
2220 panic ! ( "Must run under Unix-like platform!" ) ;
2321}
24- */
25- fn main ( ) { }
Original file line number Diff line number Diff line change @@ -256,6 +256,17 @@ mod accept {
256256 }
257257 }
258258
259+ #[ cfg( unix) ]
260+ impl Accept for tokio:: net:: UnixListener {
261+ type IO = hyper_util:: rt:: TokioIo < tokio:: net:: UnixStream > ;
262+ type AcceptError = std:: convert:: Infallible ;
263+ type Accepting = std:: future:: Ready < Result < Self :: IO , Self :: AcceptError > > ;
264+ async fn accept ( & mut self ) -> Result < Self :: Accepting , std:: io:: Error > {
265+ let ( io, _addr) = <tokio:: net:: UnixListener >:: accept ( self ) . await ?;
266+ Ok ( std:: future:: ready ( Ok ( hyper_util:: rt:: TokioIo :: new ( io) ) ) )
267+ }
268+ }
269+
259270 #[ cfg( feature = "tls" ) ]
260271 #[ derive( Debug ) ]
261272 pub struct Tls < A > ( pub ( super ) A ) ;
You can’t perform that action at this time.
0 commit comments