Browse Source

Split up into modules

master
Alex Mikhalev 4 years ago
parent
commit
4d505f383d
  1. 53
      src/lib.rs
  2. 3
      src/message.rs
  3. 20
      src/publication.rs
  4. 29
      src/subscription.rs

53
src/lib.rs

@ -1,8 +1,10 @@ @@ -1,8 +1,10 @@
use std::marker::PhantomData;
mod message;
mod publication;
mod subscription;
pub trait Message: 'static + Clone + Send + Sync {}
impl<T> 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 { @@ -36,49 +38,6 @@ impl Orsb {
}
}
#[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!()
}
}
#[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!()
}
}
#[cfg(test)]
mod test {
use super::*;

3
src/message.rs

@ -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 {}

20
src/publication.rs

@ -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!()
}
}

29
src/subscription.rs

@ -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…
Cancel
Save