diff --git a/Cargo.toml b/Cargo.toml index 3c51ebf7..7f6b3305 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,12 +61,14 @@ opentls = { version = "0.2.1", features = ["io-async-std"]} async-native-tls = { version = "0.3", features = ["runtime-async-std"]} [dependencies.tokio] -version = "1.0" +git = "https://github.com/blackbeam/tokio" +branch = "named-pipes" optional = true features = ["net", "time"] [dependencies.tokio-util] -version = "0.6" +git = "https://github.com/blackbeam/tokio" +branch = "named-pipes" features = ["compat"] optional = true @@ -109,12 +111,14 @@ optional = true features = ["std"] [dev-dependencies.tokio-util] -version = "0.6" +git = "https://github.com/blackbeam/tokio" +branch = "named-pipes" features = ["compat"] [dev-dependencies.tokio] +git = "https://github.com/blackbeam/tokio" features = ["macros", "sync", "io-std", "time", "io-util", "net", "rt-multi-thread"] -version = "1.0" +branch = "named-pipes" [dev-dependencies.async-std] features = ["attributes"] diff --git a/examples/named-pipes.rs b/examples/named-pipes.rs new file mode 100644 index 00000000..75444486 --- /dev/null +++ b/examples/named-pipes.rs @@ -0,0 +1,28 @@ +#[cfg(windows)] +#[tokio::main] +async fn main() -> anyhow::Result<()> { + use tokio::net::windows::named_pipe::NamedPipe; + use tokio_util::compat::TokioAsyncWriteCompatExt; + use tiberius::{Config, AuthMethod, Client}; + + let mut config = Config::new(); + config.authentication(AuthMethod::Integrated); + config.trust_cert(); + + let pipe = NamedPipe::connect("\\\\.\\pipe\\sql\\query").await?; + let mut client = Client::connect(config, pipe.compat_write()).await?; + + let stream = client.query("SELECT @P1", &[&1i32]).await?; + let row = stream.into_row().await?.unwrap(); + + println!("{:?}", row); + assert_eq!(Some(1), row.get(0)); + + Ok(()) +} + +#[cfg(not(windows))] +#[tokio::main] +async fn main() -> anyhow::Result<()> { + panic!("Only works on Windows."); +}