commit c8384a95c50c3136c94e8a5340641e6fe11305a1 Author: Alex Mikhalev Date: Thu Dec 24 10:48:32 2020 -0700 Add interface skeleton diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96ef6c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..5ec3276 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "orsb" +version = "0.1.0" +authors = ["Alex Mikhalev "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..b975326 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,63 @@ +use std::marker::PhantomData; + +pub trait Message: 'static + Clone + Send + Sync {} + +impl Message for T where T: 'static + Clone + Send + Sync {} + +pub struct Orsb {} + +impl Orsb { + pub fn new() -> Self { + todo!() + } + + pub fn subscribe(&mut self) -> Subscription { + todo!() + } + + pub fn advertise(&mut self) -> Publication { + todo!() + } +} + +#[derive(Clone, Debug)] +#[non_exhaustive] +pub enum RecvErr { + Empty, + Closed, + Lagged, +} + +pub struct Subscription { + _phantom: PhantomData, +} + +impl Subscription { + pub async fn recv_wait(&mut self) -> Result { + todo!() + } + + pub fn recv(&mut self) -> Result { + todo!() + } + + pub fn try_recv(&mut self) -> Result { + todo!() + } +} + +#[derive(Clone, Debug)] +#[non_exhaustive] +pub enum SendErr { + NoListeners, +} + +pub struct Publication { + _phantom: PhantomData, +} + +impl Publication { + pub fn send(&mut self) -> Result { + todo!() + } +}