|
1 | 1 | //! Implementation of the XDG secret portal. |
2 | 2 | //! |
3 | 3 | //! 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}; |
9 | 5 |
|
| 6 | +#[cfg(feature = "async-std")] |
| 7 | +use async_net::unix::UnixStream; |
| 8 | +#[cfg(feature = "async-std")] |
| 9 | +use futures_util::AsyncReadExt; |
10 | 10 | use futures_util::StreamExt; |
11 | 11 | use rand::{distributions::Alphanumeric, thread_rng, Rng}; |
| 12 | +#[cfg(feature = "tokio")] |
| 13 | +use tokio::{io::AsyncReadExt, net::UnixStream}; |
12 | 14 | use zbus::{ |
13 | 15 | zvariant::{Fd, ObjectPath, OwnedValue, SerializeDict, Type}, |
14 | 16 | ProxyDefault, |
@@ -158,13 +160,11 @@ pub async fn retrieve() -> Result<Secret, Error> { |
158 | 160 | Err(e) => Err(e.into()), |
159 | 161 | }?; |
160 | 162 |
|
161 | | - // FIXME Use async-std's (tokio's) UnixStream once |
162 | | - // https://github.com/async-rs/async-std/pull/1036 is in. |
163 | 163 | let (mut x1, x2) = UnixStream::pair()?; |
164 | 164 | proxy.retrieve_secret(&x2).await?; |
165 | 165 | drop(x2); |
166 | 166 | let mut buf = Vec::new(); |
167 | | - x1.read_to_end(&mut buf)?; |
| 167 | + x1.read_to_end(&mut buf).await?; |
168 | 168 |
|
169 | 169 | #[cfg(feature = "tracing")] |
170 | 170 | tracing::debug!("Secret received from the portal successfully"); |
|
0 commit comments