radicle: Depend on winpipe for Windows support

This commit is contained in:
Lorenz Leutgeb 2025-07-14 23:16:19 +02:00
parent 08b535d567
commit 0705501537
4 changed files with 106 additions and 7 deletions

97
Cargo.lock generated
View File

@ -650,6 +650,12 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "defer-heavy"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5053691e3e6c0e5979cfb55503b7eb4b06531897b5c15b0f617110096b05a0e1"
[[package]]
name = "der"
version = "0.7.9"
@ -1560,7 +1566,7 @@ dependencies = [
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"windows-core",
"windows-core 0.52.0",
]
[[package]]
@ -1946,9 +1952,9 @@ dependencies = [
[[package]]
name = "log"
version = "0.4.21"
version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
[[package]]
name = "maybe-async"
@ -2503,6 +2509,7 @@ dependencies = [
"tempfile",
"thiserror 1.0.69",
"unicode-normalization",
"winpipe",
]
[[package]]
@ -2745,6 +2752,7 @@ dependencies = [
"byteorder",
"log",
"thiserror 1.0.69",
"winpipe",
"zeroize",
]
@ -3408,6 +3416,12 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "sync-ptr"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b115b4cc742d11625f50e0e48ab15baf6fa548c2ec33a8d4113711886316a4f"
[[package]]
name = "synstructure"
version = "0.13.1"
@ -3892,6 +3906,16 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6"
dependencies = [
"windows-core 0.58.0",
"windows-targets 0.52.6",
]
[[package]]
name = "windows-core"
version = "0.52.0"
@ -3901,6 +3925,60 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-core"
version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
dependencies = [
"windows-implement",
"windows-interface",
"windows-result",
"windows-strings",
"windows-targets 0.52.6",
]
[[package]]
name = "windows-implement"
version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.89",
]
[[package]]
name = "windows-interface"
version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.89",
]
[[package]]
name = "windows-result"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-strings"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
dependencies = [
"windows-result",
"windows-targets 0.52.6",
]
[[package]]
name = "windows-sys"
version = "0.48.0"
@ -4058,6 +4136,19 @@ dependencies = [
"memchr",
]
[[package]]
name = "winpipe"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ccf671d62d1bd0c913d9059e69bb4a6b51f7a4c899ab83c62d921e35f206053"
dependencies = [
"defer-heavy",
"log",
"rand",
"sync-ptr",
"windows",
]
[[package]]
name = "write16"
version = "1.0.0"

View File

@ -61,6 +61,7 @@ snapbox = "0.4.3"
sqlite = "0.32.0"
tempfile = "3.3.0"
thiserror = "1.0"
winpipe = "0.1.1"
zeroize = "1.5.7"
[workspace.lints]

View File

@ -48,6 +48,9 @@ unicode-normalization = { version = "0.1" }
[target.'cfg(unix)'.dependencies]
libc = { workspace = true }
[target.'cfg(windows)'.dependencies]
winpipe = { workspace = true }
[dev-dependencies]
emojis = "0.6"
jsonschema = { version = "0.30", default-features = false }

View File

@ -19,11 +19,15 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::io::{BufRead, BufReader};
use std::marker::PhantomData;
use std::ops::{ControlFlow, Deref};
use std::os::unix::net::UnixStream;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::{fmt, io, net, thread, time};
#[cfg(unix)]
use std::os::unix::net::UnixStream as Stream;
#[cfg(windows)]
use winpipe::WinStream as Stream;
use amplify::WrapperMut;
use cyphernet::addr::NetAddr;
use localtime::{LocalDuration, LocalTime};
@ -1140,7 +1144,7 @@ pub trait Handle: Clone + Sync + Send {
/// The iterator blocks for a `timeout` duration, returning [`Error::TimedOut`]
/// if the duration is reached.
pub struct LineIter<T> {
stream: BufReader<UnixStream>,
stream: BufReader<Stream>,
timeout: time::Duration,
witness: PhantomData<T>,
}
@ -1204,9 +1208,9 @@ impl Node {
cmd: Command,
timeout: time::Duration,
) -> Result<LineIter<T>, Error> {
let stream = UnixStream::connect(&self.socket)
let mut stream = Stream::connect(&self.socket)
.map_err(|e| Error::Connect(self.socket.clone(), e.kind()))?;
cmd.to_writer(&stream)?;
cmd.to_writer(&mut stream)?;
Ok(LineIter {
stream: BufReader::new(stream),
timeout,