Skip to content

Commit e39c13b

Browse files
authored
tower-abci: v038's Server::listen_unix() is only used in unix builds (#47)
this adds a `#[cfg(target_family = "unix")]` gate to the `listen_unix` method of `Server`. this fixes a broken build on non-unix systems. --- example: ``` ; git show --oneline --quiet HEAD 4b73065 (HEAD -> main, origin/main, origin/HEAD) tower-abci: use `[email protected]` (#46) ; cargo build --quiet --target x86_64-pc-windows-msvc && echo "build passed" error[E0432]: unresolved import `tokio::net::UnixListener` --> src/v038/server.rs:9:39 | 9 | net::{TcpListener, ToSocketAddrs, UnixListener}, | ^^^^^^^^^^^^ | | | no `UnixListener` in `net` | help: a similar name exists in the module: `TcpListener` | note: found an item that was configured out --> .cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/net/mod.rs:50:29 | 50 | pub use unix::listener::UnixListener; | ^^^^^^^^^^^^ For more information about this error, try `rustc --explain E0432`. error: could not compile `tower-abci` (lib) due to 1 previous error ; git switch unix-guard-v038 branch 'unix-guard-v038' set up to track 'heliaxdev/unix-guard-v038'. Switched to a new branch 'unix-guard-v038' ; git show --oneline --quiet HEAD 52382f4 (HEAD -> unix-guard-v038, heliaxdev/unix-guard-v038) add feature guard to unix-only listener in v038 ; cargo build --quiet --target x86_64-pc-windows-msvc && echo "build passed" build passed ```
1 parent 4b73065 commit e39c13b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/v038/server.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use std::convert::{TryFrom, TryInto};
2-
use std::path::Path;
32

43
use futures::future::{FutureExt, TryFutureExt};
54
use futures::sink::SinkExt;
65
use futures::stream::{FuturesOrdered, StreamExt};
76
use tokio::io::{AsyncReadExt, AsyncWriteExt};
87
use tokio::{
9-
net::{TcpListener, ToSocketAddrs, UnixListener},
8+
net::{TcpListener, ToSocketAddrs},
109
select,
1110
};
1211
use tokio_util::codec::{FramedRead, FramedWrite};
@@ -126,8 +125,9 @@ where
126125
ServerBuilder::default()
127126
}
128127

129-
pub async fn listen_unix(self, path: impl AsRef<Path>) -> Result<(), BoxError> {
130-
let listener = UnixListener::bind(path)?;
128+
#[cfg(target_family = "unix")]
129+
pub async fn listen_unix(self, path: impl AsRef<std::path::Path>) -> Result<(), BoxError> {
130+
let listener = tokio::net::UnixListener::bind(path)?;
131131
let addr = listener.local_addr()?;
132132
tracing::info!(?addr, "ABCI server starting on uds");
133133

0 commit comments

Comments
 (0)