Skip to content

Commit

Permalink
secret: retrieve: Accept AsFd as argument
Browse files Browse the repository at this point in the history
This is more general. Since BorrowedFd implements AsFd this should not
really break users.
  • Loading branch information
A6GibKm committed Sep 21, 2024
1 parent e4f64c4 commit 18c0ccc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/desktop/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! let secret = Secret::new().await?;
//!
//! let (mut x1, x2) = std::os::unix::net::UnixStream::pair()?;
//! secret.retrieve(&x2.as_fd()).await?;
//! secret.retrieve(&x2).await?;
//! drop(x2);
//! let mut buf = Vec::new();
//! x1.read_to_end(&mut buf)?;
Expand All @@ -18,7 +18,7 @@
//! }
//! ```
use std::os::fd::{AsFd, BorrowedFd};
use std::os::fd::AsFd;

#[cfg(feature = "async-std")]
use async_net::{unix::UnixStream, Shutdown};
Expand Down Expand Up @@ -68,7 +68,7 @@ impl<'a> Secret<'a> {
///
/// See also [`RetrieveSecret`](https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Secret.html#org-freedesktop-portal-secret-retrievesecret)
#[doc(alias = "RetrieveSecret")]
pub async fn retrieve(&self, fd: &BorrowedFd<'_>) -> Result<Request<()>, Error> {
pub async fn retrieve(&self, fd: &impl AsFd) -> Result<Request<()>, Error> {
let options = RetrieveOptions::default();
self.0
.empty_request(
Expand Down Expand Up @@ -98,14 +98,14 @@ pub async fn retrieve() -> Result<Vec<u8>, Error> {
#[cfg(feature = "tokio")]
let mut x1 = {
let (x1, mut x2) = UnixStream::pair()?;
proxy.retrieve(&x2.as_fd()).await?;
proxy.retrieve(&x2).await?;
x2.shutdown().await?;
x1
};
#[cfg(feature = "async-std")]
let mut x1 = {
let (x1, x2) = UnixStream::pair()?;
proxy.retrieve(&x2.as_fd()).await?;
proxy.retrieve(&x2).await?;
x2.shutdown(Shutdown::Both)?;
x1
};
Expand Down

0 comments on commit 18c0ccc

Please sign in to comment.