pub struct Device { /* private fields */ }
Expand description
Represents a Miio device with its associated properties and Python object.
The Device struct includes data necessary for device communication and method invocation, along with functionalities to serialize/deserialize the device configuration.
Implementations§
Source§impl Device
impl Device
Sourcepub fn create_device(
ip: &str,
token: &str,
device_type: &str,
) -> Result<Device, PyErr>
pub fn create_device( ip: &str, token: &str, device_type: &str, ) -> Result<Device, PyErr>
Creates a new Device instance by invoking the Python function.
This function calls the Python module to create a device and retrieve its properties, including serialized state and callable methods.
§Arguments
ip
- The IP address of the device.token
- The token used for authentication.device_type
- The type of the device.
§Returns
Ok(Device)
on success.Err(PyErr)
if any Python call fails.
Sourcepub fn call_method(
&self,
method_name: &str,
args: Vec<&str>,
) -> Result<String, PyErr>
pub fn call_method( &self, method_name: &str, args: Vec<&str>, ) -> Result<String, PyErr>
Calls a method on the device by invoking the corresponding Python function.
This function sends a command to the device through Python and returns the result.
§Arguments
method_name
- The name of the method to be called.args
- A vector of string arguments for the method.
§Returns
Ok(String)
containing the result if successful.Err(PyErr)
if the Python call fails.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Device
impl<'de> Deserialize<'de> for Device
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Device
impl RefUnwindSafe for Device
impl Send for Device
impl Sync for Device
impl Unpin for Device
impl UnwindSafe for Device
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