diff --git a/Cargo.toml b/Cargo.toml index f3acaec..9e6d46e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,9 @@ version = "0.1.0" authors = ["Tony Garnock-Jones "] edition = "2018" +[lib] +name = "syndicate" + [dependencies] preserves = "0.3.1" diff --git a/src/main.rs b/src/bin/syndicate-server.rs similarity index 58% rename from src/main.rs rename to src/bin/syndicate-server.rs index f699284..2785bad 100644 --- a/src/main.rs +++ b/src/bin/syndicate-server.rs @@ -1,35 +1,8 @@ -#![recursion_limit="512"] +use syndicate::{peer, spaces}; -mod bag; -mod dataspace; -mod packets; -mod peer; -mod skeleton; -mod spaces; - -use preserves::value; use std::sync::{Mutex, Arc}; use tokio::net::TcpListener; -use std::sync::atomic::{AtomicUsize, Ordering}; - -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum Syndicate { - Placeholder(usize), -} - -impl value::Domain for Syndicate {} - -static NEXT_PLACEHOLDER: AtomicUsize = AtomicUsize::new(0); -impl Syndicate { - pub fn new_placeholder() -> Self { - Self::Placeholder(NEXT_PLACEHOLDER.fetch_add(1, Ordering::SeqCst)) - } -} - -pub type ConnId = u64; -pub type V = value::ArcValue; - #[tokio::main] async fn main() -> Result<(), Box> { let spaces = Arc::new(Mutex::new(spaces::Spaces::new())); diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..3f8aa48 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,29 @@ +#![recursion_limit="512"] + +pub mod bag; +pub mod dataspace; +pub mod packets; +pub mod peer; +pub mod skeleton; +pub mod spaces; + +pub use preserves::value; + +use std::sync::atomic::{AtomicUsize, Ordering}; + +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum Syndicate { + Placeholder(usize), +} + +impl value::Domain for Syndicate {} + +static NEXT_PLACEHOLDER: AtomicUsize = AtomicUsize::new(0); +impl Syndicate { + pub fn new_placeholder() -> Self { + Self::Placeholder(NEXT_PLACEHOLDER.fetch_add(1, Ordering::SeqCst)) + } +} + +pub type ConnId = u64; +pub type V = value::ArcValue;