Skip to content

Commit 1ee9906

Browse files
client: Use async UnixStream
1 parent 0434fbd commit 1ee9906

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

client/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ aes = { version = "0.8", features = ["zeroize"], optional = true }
1717
async-fs = { version = "2.1.0", optional = true }
1818
async-io = { version = "2.2.2", optional = true }
1919
async-lock = { version = "3.2.0", optional = true }
20+
async-net = { version = "2.0.0", optional = true }
2021
blocking = { version = "1.5.1", optional = true }
2122
cbc = { version = "0.1", features = ["zeroize"], optional = true }
2223
cipher = { version = "0.4", features = [
@@ -64,6 +65,7 @@ async-std = [
6465
"dep:async-fs",
6566
"dep:async-io",
6667
"dep:async-lock",
68+
"dep:async-net",
6769
"dep:blocking",
6870
"dep:futures-lite",
6971
]

client/src/portal/secret.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
//! Implementation of the XDG secret portal.
22
//!
33
//! This is a modified copy from ASHPD.
4-
use std::{
5-
collections::HashMap,
6-
io::Read,
7-
os::{fd::AsFd, unix::net::UnixStream},
8-
};
4+
use std::{collections::HashMap, os::fd::AsFd};
95

6+
#[cfg(feature = "async-std")]
7+
use async_net::unix::UnixStream;
8+
#[cfg(feature = "async-std")]
9+
use futures_util::AsyncReadExt;
1010
use futures_util::StreamExt;
1111
use rand::{distributions::Alphanumeric, thread_rng, Rng};
12+
#[cfg(feature = "tokio")]
13+
use tokio::{io::AsyncReadExt, net::UnixStream};
1214
use zbus::{
1315
zvariant::{Fd, ObjectPath, OwnedValue, SerializeDict, Type},
1416
ProxyDefault,
@@ -158,13 +160,11 @@ pub async fn retrieve() -> Result<Secret, Error> {
158160
Err(e) => Err(e.into()),
159161
}?;
160162

161-
// FIXME Use async-std's (tokio's) UnixStream once
162-
// https://github.com/async-rs/async-std/pull/1036 is in.
163163
let (mut x1, x2) = UnixStream::pair()?;
164164
proxy.retrieve_secret(&x2).await?;
165165
drop(x2);
166166
let mut buf = Vec::new();
167-
x1.read_to_end(&mut buf)?;
167+
x1.read_to_end(&mut buf).await?;
168168

169169
#[cfg(feature = "tracing")]
170170
tracing::debug!("Secret received from the portal successfully");

0 commit comments

Comments
 (0)