Browse Source

Add interface skeleton

master
Alex Mikhalev 4 years ago
commit
c8384a95c5
  1. 2
      .gitignore
  2. 9
      Cargo.toml
  3. 63
      src/lib.rs

2
.gitignore vendored

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
/target
Cargo.lock

9
Cargo.toml

@ -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]

63
src/lib.rs

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