Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86c32463 authored by Rahul Arya's avatar Rahul Arya Committed by Automerger Merge Worker
Browse files

Merge changes Ie8c0ac85,If3447096,Ib11c0789,I581fec49 am: 596b4643

parents c87c5246 596b4643
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -49,9 +49,9 @@ impl<T> Deref for SharedBox<T> {
}

/// A weak reference to the contents within a SharedBox<>
pub struct WeakBox<T>(Weak<T>);
pub struct WeakBox<T: ?Sized>(Weak<T>);

impl<T> WeakBox<T> {
impl<T: ?Sized> WeakBox<T> {
    /// Fallibly upgrade to a strong reference, passed into the supplied closure.
    /// The strong reference is not passed into the closure to avoid accidental
    /// lifetime extension.
@@ -64,16 +64,16 @@ impl<T> WeakBox<T> {
    }
}

impl<T> Clone for WeakBox<T> {
impl<T: ?Sized> Clone for WeakBox<T> {
    fn clone(&self) -> Self {
        Self(self.0.clone())
    }
}

/// A strong reference to the contents within a SharedBox<>.
pub struct WeakBoxRef<'a, T>(&'a T, Weak<T>);
pub struct WeakBoxRef<'a, T: ?Sized>(&'a T, Weak<T>);

impl<'a, T> WeakBoxRef<'a, T> {
impl<'a, T: ?Sized> WeakBoxRef<'a, T> {
    /// Downgrade to a weak reference (with static lifetime) to the contents
    /// within the underlying SharedBox<>
    pub fn downgrade(&self) -> WeakBox<T> {
@@ -81,10 +81,16 @@ impl<'a, T> WeakBoxRef<'a, T> {
    }
}

impl<'a, T> Deref for WeakBoxRef<'a, T> {
impl<'a, T: ?Sized> Deref for WeakBoxRef<'a, T> {
    type Target = T;

    fn deref(&self) -> &Self::Target {
        self.0
    }
}

impl<'a, T: ?Sized> Clone for WeakBoxRef<'a, T> {
    fn clone(&self) -> Self {
        Self(self.0, self.1.clone())
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -163,7 +163,9 @@ fn on_le_disconnect(tcb_idx: u8) {
    if let Some(conn_id) = with_arbiter(|arbiter| arbiter.on_le_disconnect(TransportIndex(tcb_idx)))
    {
        do_in_rust_thread(move |modules| {
            modules.gatt_module.on_le_disconnect(conn_id);
            if let Err(err) = modules.gatt_module.on_le_disconnect(conn_id) {
                error!("{err:?}")
            }
        })
    }
}
+5 −1
Original line number Diff line number Diff line
@@ -358,7 +358,11 @@ fn add_service(server_id: u8, service_records: Vec<GattRecord>) {
        Ok(service) => {
            let handle = service.handle;
            do_in_rust_thread(move |modules| {
                let ok = modules.gatt_module.register_gatt_service(server_id, service.clone());
                let ok = modules.gatt_module.register_gatt_service(
                    server_id,
                    service.clone(),
                    modules.gatt_incoming_callbacks.clone(),
                );
                match ok {
                    Ok(_) => info!(
                        "successfully registered service for server {server_id:?} with handle {handle:?} (service={service:?})"
+9 −0
Original line number Diff line number Diff line
@@ -43,3 +43,12 @@ pub struct AdvertiserId(pub u8);
/// The handle of a given ATT attribute
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct AttHandle(pub u16);

impl AttHandle {
    /// The (only) reserved AttHandle
    pub const RESERVED: Self = AttHandle(0);
    /// The smallest valid AttHandle
    pub const MIN: Self = AttHandle(1);
    /// The largest valid AttHandle
    pub const MAX: Self = AttHandle(0xFFFF);
}
+1 −0
Original line number Diff line number Diff line
//! Mocks for the GattDatastore + AttTransport traits, for use in test
pub mod mock_callbacks;
pub mod mock_database_callbacks;
pub mod mock_datastore;
pub mod mock_transport;
Loading