pub struct ClientAttached(/* private fields */);Expand description
A connection to wpa_supplicant / hostapd that receives status messages
Implementations§
Source§impl ClientAttached
impl ClientAttached
Sourcepub fn detach(self) -> Result<Client>
pub fn detach(self) -> Result<Client>
Stop listening for and discard any remaining control interface messages
§Examples
let mut wpa = wpactrl::Client::builder().open().unwrap().attach().unwrap();
wpa.detach().unwrap();§Errors
Error::Detach- Unexpected (non-OK) responseError::Io- Low-level I/O errorError::Utf8ToStr- Corrupted message or message with non-UTF8 charactersError::Wait- Failed to wait on underlying Unix socket
Sourcepub fn recv(&mut self) -> Result<Option<String>>
pub fn recv(&mut self) -> Result<Option<String>>
Receive the next control interface message.
Note that multiple control interface messages can be pending; call this function repeatedly until it returns None to get all of them.
§Examples
let mut wpa = wpactrl::Client::builder().open().unwrap().attach().unwrap();
assert_eq!(wpa.recv().unwrap(), None);§Errors
Error::Io- Low-level I/O errorError::Utf8ToStr- Corrupted message or message with non-UTF8 charactersError::Wait- Failed to wait on underlying Unix socket
Sourcepub fn request(&mut self, cmd: &str) -> Result<String>
pub fn request(&mut self, cmd: &str) -> Result<String>
Send a command to wpa_supplicant / hostapd.
Commands are generally identical to those used in wpa_cli,
except all uppercase (eg LIST_NETWORKS, SCAN, etc)
Control interface messages will be buffered as the command runs, and will be returned on the next call to recv.
§Examples
let mut wpa = wpactrl::Client::builder().open().unwrap();
assert_eq!(wpa.request("PING").unwrap(), "PONG\n");§Errors
Error::Io- Low-level I/O errorError::Utf8ToStr- Corrupted message or message with non-UTF8 charactersError::Wait- Failed to wait on underlying Unix socket
Auto Trait Implementations§
impl Freeze for ClientAttached
impl RefUnwindSafe for ClientAttached
impl Send for ClientAttached
impl Sync for ClientAttached
impl Unpin for ClientAttached
impl UnwindSafe for ClientAttached
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more