Alex Mikhalev
4 years ago
commit
c8384a95c5
3 changed files with 74 additions and 0 deletions
@ -0,0 +1,9 @@
@@ -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] |
@ -0,0 +1,63 @@
@@ -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…
Reference in new issue