diff --git a/src/lib.rs b/src/lib.rs index 5083abf..ea8cd08 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,10 @@ -use std::marker::PhantomData; +mod message; +mod publication; +mod subscription; -pub trait Message: 'static + Clone + Send + Sync {} - -impl Message for T where T: 'static + Clone + Send + Sync {} +pub use message::Message; +pub use publication::{Publication, SendError}; +pub use subscription::{RecvError, Subscription}; #[derive(Clone, Debug, PartialEq)] #[non_exhaustive] @@ -36,49 +38,6 @@ impl Orsb { } } -#[derive(Clone, Debug, PartialEq)] -#[non_exhaustive] -pub enum RecvError { - Empty, - Closed, - Lagged, -} - -pub struct Subscription { - _phantom: PhantomData, -} - -impl Subscription { - pub async fn recv(&mut self) -> Result { - todo!() - } - - pub fn recv_blocking(&mut self) -> Result { - todo!() - } - - pub fn try_recv(&mut self) -> Result { - todo!() - } -} - -#[derive(Clone, Debug, PartialEq)] -#[non_exhaustive] -pub enum SendError { - NoListeners, -} - -pub struct Publication { - _phantom: PhantomData, -} - -impl Publication { - pub fn send(&mut self, message: T) -> Result<(), SendError> { - let _ = message; - todo!() - } -} - #[cfg(test)] mod test { use super::*; diff --git a/src/message.rs b/src/message.rs new file mode 100644 index 0000000..093d7fa --- /dev/null +++ b/src/message.rs @@ -0,0 +1,3 @@ +pub trait Message: 'static + Clone + Send + Sync {} + +impl Message for T where T: 'static + Clone + Send + Sync {} diff --git a/src/publication.rs b/src/publication.rs new file mode 100644 index 0000000..dc1ccaa --- /dev/null +++ b/src/publication.rs @@ -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 { + _phantom: PhantomData, +} + +impl Publication { + pub fn send(&mut self, message: T) -> Result<(), SendError> { + let _ = message; + todo!() + } +} diff --git a/src/subscription.rs b/src/subscription.rs new file mode 100644 index 0000000..6c338e9 --- /dev/null +++ b/src/subscription.rs @@ -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 { + _phantom: PhantomData, +} + +impl Subscription { + pub async fn recv(&mut self) -> Result { + todo!() + } + + pub fn recv_blocking(&mut self) -> Result { + todo!() + } + + pub fn try_recv(&mut self) -> Result { + todo!() + } +}