PR feedback

This commit is contained in:
Marshall Pierce
2023-07-26 13:32:12 -06:00
parent afb21220e2
commit 91971433d2
14 changed files with 163 additions and 151 deletions

View File

@@ -14,15 +14,15 @@
//! GATT profiles
use crate::wrapper::{gatt::Characteristic, gatt_client::ProfileServiceProxy};
use crate::wrapper::gatt_client::{CharacteristicProxy, ProfileServiceProxy};
use pyo3::{intern, PyObject, PyResult, Python};
/// Exposes the battery GATT service
pub struct BatteryService(PyObject);
pub struct BatteryServiceProxy(PyObject);
impl BatteryService {
impl BatteryServiceProxy {
/// Get the battery level, if available
pub fn battery_level(&self) -> PyResult<Option<Characteristic>> {
pub fn battery_level(&self) -> PyResult<Option<CharacteristicProxy>> {
Python::with_gil(|py| {
self.0
.getattr(py, intern!(py, "battery_level"))
@@ -30,14 +30,14 @@ impl BatteryService {
if level.is_none(py) {
None
} else {
Some(Characteristic(level))
Some(CharacteristicProxy(level))
}
})
})
}
}
impl ProfileServiceProxy for BatteryService {
impl ProfileServiceProxy for BatteryServiceProxy {
const PROXY_CLASS_MODULE: &'static str = "bumble.profiles.battery_service";
const PROXY_CLASS_NAME: &'static str = "BatteryServiceProxy";