diff options
Diffstat (limited to 'rust/src/wrapper/profile.rs')
-rw-r--r-- | rust/src/wrapper/profile.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/rust/src/wrapper/profile.rs b/rust/src/wrapper/profile.rs index 854ba80..fc473ff 100644 --- a/rust/src/wrapper/profile.rs +++ b/rust/src/wrapper/profile.rs @@ -14,7 +14,10 @@ //! GATT profiles -use crate::wrapper::gatt_client::{CharacteristicProxy, ProfileServiceProxy}; +use crate::wrapper::{ + gatt_client::{CharacteristicProxy, ProfileServiceProxy}, + PyObjectExt, +}; use pyo3::{intern, PyObject, PyResult, Python}; /// Exposes the battery GATT service @@ -26,13 +29,7 @@ impl BatteryServiceProxy { Python::with_gil(|py| { self.0 .getattr(py, intern!(py, "battery_level")) - .map(|level| { - if level.is_none(py) { - None - } else { - Some(CharacteristicProxy(level)) - } - }) + .map(|level| level.into_option(CharacteristicProxy)) }) } } |