From 18c0cccf0a5a473c58c5eaf4578220708976004b Mon Sep 17 00:00:00 2001 From: Maximiliano Sandoval Date: Sun, 22 Sep 2024 00:20:41 +0200 Subject: [PATCH] secret: retrieve: Accept AsFd as argument This is more general. Since BorrowedFd implements AsFd this should not really break users. --- src/desktop/secret.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/desktop/secret.rs b/src/desktop/secret.rs index dfee4eff7..f6fe812ed 100644 --- a/src/desktop/secret.rs +++ b/src/desktop/secret.rs @@ -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)?; @@ -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}; @@ -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, Error> { + pub async fn retrieve(&self, fd: &impl AsFd) -> Result, Error> { let options = RetrieveOptions::default(); self.0 .empty_request( @@ -98,14 +98,14 @@ pub async fn retrieve() -> Result, 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 };