Repository: FactbirdHQ/atat (language: rust)

Issue:
Subscriber does not feature the "Send" Trait
When doing ATAT on tokio, it seems appropriate, and in fact demonstrates a great feature provided with this crate, to `tokio::spawn` multiple  threads for multiple subscribers fetched by  `BUFFERS.urc_channel.subscribe();`  
I was not able to do this as seemingly the `DynSubscriber`   struct returned does not feature `Send`  which is necessary for using it as an argument for the async fn to be spawned by tokio. 
(As a workaround I currently only use one subscriber and use it in a main thread loop by `let urc_handle = subscriber.next_message();`  - while doing the `client.send()`  activity in a tokio thread.

`dyn PubSubBehavior<urc::Urc> cannot be shared between threads safely ... required by a bound introduced by this call`

Suggestion: 
while `embassy_sync::pubsub::DynSubscriber` does not feature `Send`, `embassy_sync::pubsub::Subscriber`  seemingly does.

-Michael


Discussion / hints:
@rmja would there be any issues changing it from `DynSubscriber` to `Subscriber`, apart from the extra annoying generic parameter?
I don't think so. That would be a fine change.

Fix patch:
diff --git a/atat/src/urc_channel.rs b/atat/src/urc_channel.rs
index 713a7670..a1098eba 100644
--- a/atat/src/urc_channel.rs
+++ b/atat/src/urc_channel.rs
@@ -1,11 +1,12 @@
 use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
-use embassy_sync::pubsub::{DynSubscriber, PubSubBehavior, PubSubChannel, Publisher};
+use embassy_sync::pubsub::{PubSubBehavior, PubSubChannel, Publisher, Subscriber};
 
 use crate::AtatUrc;
 
 pub type UrcPublisher<'sub, Urc, const CAPACITY: usize, const SUBSCRIBERS: usize> =
     Publisher<'sub, CriticalSectionRawMutex, <Urc as AtatUrc>::Response, CAPACITY, SUBSCRIBERS, 1>;
-pub type UrcSubscription<'sub, Urc> = DynSubscriber<'sub, <Urc as AtatUrc>::Response>;
+pub type UrcSubscription<'sub, Urc, const CAPACITY: usize, const SUBSCRIBERS: usize> =
+    Subscriber<'sub, CriticalSectionRawMutex, <Urc as AtatUrc>::Response, CAPACITY, SUBSCRIBERS, 1>;
 
 #[derive(Clone, Debug, PartialEq, Eq)]
 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
@@ -13,8 +14,8 @@ pub enum Error {
     MaximumSubscribersReached,
 }
 
-pub trait AtatUrcChannel<Urc: AtatUrc> {
-    fn subscribe(&self) -> Result<UrcSubscription<'_, Urc>, Error>;
+pub trait AtatUrcChannel<Urc: AtatUrc, const CAPACITY: usize, const SUBSCRIBERS: usize> {
+    fn subscribe(&self) -> Result<UrcSubscription<'_, Urc, CAPACITY, SUBSCRIBERS>, Error>;
     fn space(&self) -> usize;
 }
 
@@ -34,12 +35,12 @@ impl<Urc: AtatUrc, const CAPACITY: usize, const SUBSCRIBERS: usize>
     }
 }
 
-impl<Urc: AtatUrc, const CAPACITY: usize, const SUBSCRIBERS: usize> AtatUrcChannel<Urc>
-    for UrcChannel<Urc, CAPACITY, SUBSCRIBERS>
+impl<Urc: AtatUrc, const CAPACITY: usize, const SUBSCRIBERS: usize>
+    AtatUrcChannel<Urc, CAPACITY, SUBSCRIBERS> for UrcChannel<Urc, CAPACITY, SUBSCRIBERS>
 {
-    fn subscribe(&self) -> Result<UrcSubscription<'_, Urc>, Error> {
+    fn subscribe(&self) -> Result<UrcSubscription<'_, Urc, CAPACITY, SUBSCRIBERS>, Error> {
         self.0
-            .dyn_subscriber()
+            .subscriber()
             .map_err(|_| Error::MaximumSubscribersReached)
     }
 


Test patch: