Split up into modules
This commit is contained in:
		
							parent
							
								
									4623cea844
								
							
						
					
					
						commit
						4d505f383d
					
				
							
								
								
									
										53
									
								
								src/lib.rs
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								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<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 { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #[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
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/message.rs
									
									
									
									
									
										Normal file
									
								
							| @ -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
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/publication.rs
									
									
									
									
									
										Normal file
									
								
							| @ -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
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/subscription.rs
									
									
									
									
									
										Normal file
									
								
							| @ -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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user