Skip to content

Implement AsRawFd for PpsDevice#5

Merged
davidv1992 merged 1 commit into
pendulum-project:mainfrom
Erk-:asrawfd
Jun 11, 2026
Merged

Implement AsRawFd for PpsDevice#5
davidv1992 merged 1 commit into
pendulum-project:mainfrom
Erk-:asrawfd

Conversation

@Erk-

@Erk- Erk- commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

I want this to allow for more direct usage, more specifically I wanted to allow this usage:

use pps_time::PpsDevice;
use tokio::io::{Interest, unix::AsyncFd};

struct AsyncPps {
    inner: AsyncFd<PpsDevice>,
}

impl AsyncPps {
    fn new(pps: PpsDevice) -> std::io::Result<Self> {
        Ok(AsyncPps { inner: AsyncFd::new(pps)?, })
    }

    pub async fn wait(&self) -> std::io::Result<()> {
        let mut guard = self.inner.ready(Interest::READABLE).await?;
        guard.clear_ready();
        Ok(())
    }
}

I think this is nicer than to allow access to the underlying File.

@davidv1992

Copy link
Copy Markdown
Member

This crate is primarily intended by us for pps in ntpd-rs, which has a bunch of minor things which we want to clean up eventually. Is this motivated by wanting to clean up there, or by a usecase you have for this crate?

@Erk-

Erk- commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

This was mainly motivated by a use case for the library (misusing pps as a global 10hz sync signal). And I wanted to be able to use it from Tokio.

#6 was just a small annoyance I had when I experimented with the library.

@davidv1992 davidv1992 merged commit 0e992eb into pendulum-project:main Jun 11, 2026
1 check passed
@davidv1992

Copy link
Copy Markdown
Member

This looks like good changes. Just can't promise we will ever make a release with these, as we are currently doing rather large refactors around ntpd-rs and I'm not sure we are going to keep this crate in its current form.

@Erk- Erk- deleted the asrawfd branch June 11, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants