Alex Mikhalev
4 years ago
4 changed files with 58 additions and 47 deletions
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
pub trait Message: 'static + Clone + Send + Sync {} |
||||
|
||||
impl<T> Message for T where T: 'static + Clone + Send + Sync {} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
use std::marker::PhantomData; |
||||
|
||||
use crate::message::Message; |
||||
|
||||
#[derive(Clone, Debug, PartialEq)] |
||||
#[non_exhaustive] |
||||
pub enum SendError { |
||||
NoListeners, |
||||
} |
||||
|
||||
pub struct Publication<T> { |
||||
_phantom: PhantomData<T>, |
||||
} |
||||
|
||||
impl<T: Message> Publication<T> { |
||||
pub fn send(&mut self, message: T) -> Result<(), SendError> { |
||||
let _ = message; |
||||
todo!() |
||||
} |
||||
} |
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
use std::marker::PhantomData; |
||||
|
||||
use crate::message::Message; |
||||
|
||||
#[derive(Clone, Debug, PartialEq)] |
||||
#[non_exhaustive] |
||||
pub enum RecvError { |
||||
Empty, |
||||
Closed, |
||||
Lagged, |
||||
} |
||||
|
||||
pub struct Subscription<T> { |
||||
_phantom: PhantomData<T>, |
||||
} |
||||
|
||||
impl<T: Message> Subscription<T> { |
||||
pub async fn recv(&mut self) -> Result<T, RecvError> { |
||||
todo!() |
||||
} |
||||
|
||||
pub fn recv_blocking(&mut self) -> Result<T, RecvError> { |
||||
todo!() |
||||
} |
||||
|
||||
pub fn try_recv(&mut self) -> Result<T, RecvError> { |
||||
todo!() |
||||
} |
||||
} |
Loading…
Reference in new issue