Skip to content

impl AsRawFd for Client and ClientAttached #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/wpactrl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ impl ClientInternal {
}
}

impl AsRawFd for ClientInternal {
fn as_raw_fd(&self) -> RawFd {
self.handle.as_raw_fd()
}
}

impl Drop for ClientInternal {
fn drop(&mut self) {
if let Err(e) = std::fs::remove_file(&self.filepath) {
Expand Down Expand Up @@ -248,6 +254,12 @@ impl Client {
}
}

impl AsRawFd for Client {
fn as_raw_fd(&self) -> RawFd {
self.0.as_raw_fd()
}
}

/// A connection to `wpa_supplicant` / `hostapd` that receives status messages
pub struct ClientAttached(ClientInternal, VecDeque<String>);

Expand Down Expand Up @@ -328,6 +340,12 @@ impl ClientAttached {
}
}

impl AsRawFd for ClientAttached {
fn as_raw_fd(&self) -> RawFd {
self.0.as_raw_fd()
}
}

#[cfg(test)]
mod test {
use serial_test::serial;
Expand Down