btleplug icon indicating copy to clipboard operation
btleplug copied to clipboard

add PeripheralId new method for Android and Linux

Open Yongle-Fu opened this issue 1 year ago • 0 comments

pub fn to_peripheral_id(id: &str) -> PeripheralId {

    #[cfg(any(target_os = "macos", target_os = "ios"))]
    return PeripheralId::from(Uuid::parse_str(id_str).unwrap());

    #[cfg(target_os = "windows")]
    PeripheralId::from(BDAddr::from_str_delim(&id_str).unwrap())

    #[cfg(target_os = "android")]
    return PeripheralId(BDAddr::from_str_delim(&id_str).unwrap());

    #[cfg(target_os = "linux")]
    return PeripheralId::from(bluez_async::DeviceId::new(id));
}

why not provide public method

droidplug/peripheral.rs:42:25 | 42 | pub struct PeripheralId(pub(super) BDAddr); | ^^^^^^^^^^^^^^^^^ private field

bluez-async-0.8.0/src/device.rs:22:5 | 22 | pub(crate) fn new(object_path: &str) -> Self { | -------------------------------------------- private associated function defined here

Yongle-Fu avatar Aug 23 '24 07:08 Yongle-Fu