Add interface skeleton
This commit is contained in:
		
						commit
						c8384a95c5
					
				
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| /target | ||||
| Cargo.lock | ||||
							
								
								
									
										9
									
								
								Cargo.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								Cargo.toml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| [package] | ||||
| name = "orsb" | ||||
| version = "0.1.0" | ||||
| authors = ["Alex Mikhalev <alexmikhalevalex@gmail.com>"] | ||||
| edition = "2018" | ||||
| 
 | ||||
| # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||||
| 
 | ||||
| [dependencies] | ||||
							
								
								
									
										63
									
								
								src/lib.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								src/lib.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,63 @@ | ||||
| use std::marker::PhantomData; | ||||
| 
 | ||||
| pub trait Message: 'static + Clone + Send + Sync {} | ||||
| 
 | ||||
| impl<T> Message for T where T: 'static + Clone + Send + Sync {} | ||||
| 
 | ||||
| pub struct Orsb {} | ||||
| 
 | ||||
| impl Orsb { | ||||
|     pub fn new() -> Self { | ||||
|         todo!() | ||||
|     } | ||||
| 
 | ||||
|     pub fn subscribe<T: Message>(&mut self) -> Subscription<T> { | ||||
|         todo!() | ||||
|     } | ||||
| 
 | ||||
|     pub fn advertise<T: Message>(&mut self) -> Publication<T> { | ||||
|         todo!() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #[derive(Clone, Debug)] | ||||
| #[non_exhaustive] | ||||
| pub enum RecvErr { | ||||
|     Empty, | ||||
|     Closed, | ||||
|     Lagged, | ||||
| } | ||||
| 
 | ||||
| pub struct Subscription<T> { | ||||
|     _phantom: PhantomData<T>, | ||||
| } | ||||
| 
 | ||||
| impl<T: Message> Subscription<T> { | ||||
|     pub async fn recv_wait(&mut self) -> Result<T, RecvErr> { | ||||
|         todo!() | ||||
|     } | ||||
| 
 | ||||
|     pub fn recv(&mut self) -> Result<T, RecvErr> { | ||||
|         todo!() | ||||
|     } | ||||
| 
 | ||||
|     pub fn try_recv(&mut self) -> Result<T, RecvErr> { | ||||
|         todo!() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #[derive(Clone, Debug)] | ||||
| #[non_exhaustive] | ||||
| pub enum SendErr { | ||||
|     NoListeners, | ||||
| } | ||||
| 
 | ||||
| pub struct Publication<T> { | ||||
|     _phantom: PhantomData<T>, | ||||
| } | ||||
| 
 | ||||
| impl<T: Message> Publication<T> { | ||||
|     pub fn send(&mut self) -> Result<T, SendErr> { | ||||
|         todo!() | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user