Split out binary from library

This commit is contained in:
Tony Garnock-Jones 2020-05-11 20:51:04 +02:00
parent d05dd10c14
commit 87bcaacaa4
3 changed files with 33 additions and 28 deletions

View File

@ -4,6 +4,9 @@ version = "0.1.0"
authors = ["Tony Garnock-Jones <tonyg@leastfixedpoint.com>"]
edition = "2018"
[lib]
name = "syndicate"
[dependencies]
preserves = "0.3.1"

View File

@ -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<Syndicate>;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let spaces = Arc::new(Mutex::new(spaces::Spaces::new()));

29
src/lib.rs Normal file
View File

@ -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<Syndicate>;