state: start

clone-session-service-objects
Avril 4 years ago
parent 98fdc1890d
commit a277f3fd9d
Signed by: flanchan
GPG Key ID: 284488987C31F630

1
Cargo.lock generated

@ -1401,6 +1401,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"difference", "difference",
"futures", "futures",
"once_cell",
"serde", "serde",
"smallvec", "smallvec",
"tokio", "tokio",

@ -13,6 +13,7 @@ nightly = ["smallvec/const_generics"]
[dependencies] [dependencies]
difference = "2.0.0" difference = "2.0.0"
futures = "0.3.8" futures = "0.3.8"
once_cell = "1.5.2"
serde = {version = "1.0.118", features=["derive"]} serde = {version = "1.0.118", features=["derive"]}
smallvec = {version = "1.6.0", features= ["union", "serde", "write"]} smallvec = {version = "1.6.0", features= ["union", "serde", "write"]}
tokio = {version = "0.2", features=["full"] } tokio = {version = "0.2", features=["full"] }

@ -8,6 +8,7 @@
#[macro_use] mod ext; use ext::*; #[macro_use] mod ext; use ext::*;
mod delta; mod delta;
mod state;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {

@ -0,0 +1,33 @@
//! Open post body
use super::*;
use tokio::{
sync::{
watch,
mpsc,
},
};
use once_cell::sync::OnceCell;
/// An open post body
#[derive(Debug)]
pub struct Karada
{
scape: Vec<char>,
body_cache: String,
//TODO: Pub/sub? Or should that be in some other place? Probably.
}
impl Karada
{
fn invalidate_cache(&mut self)
{
self.body_cache = self.scape.iter().copied().collect();
}
/// Apply this delta to the body.
pub fn apply_delta(&mut self, delta: &delta::Delta)
{
delta.insert(&mut self.scape);
self.invalidate_cache();
}
}

@ -0,0 +1,5 @@
use super::*;
pub mod user;
pub mod post;
pub mod body;

@ -0,0 +1,28 @@
use super::*;
#[derive(Debug)]
pub struct OpenPost
{
}
#[derive(Debug)]
pub struct ClosedPost
{
}
#[derive(Debug)]
pub enum PostKind
{
Open(OpenPost),
Closed(ClosedPost),
}
/// A post
#[derive(Debug)]
pub struct Post
{
owner: user::UserID,
kind: PostKind
}

@ -0,0 +1,7 @@
//! Used to determine which post belongs to who.
//!
//! Mostly for determining if a poster owns a post.
use super::*;
#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Hash)]
pub struct UserID(()); //TODO: User ID. Maybe use IP + session ID hash?
Loading…
Cancel
Save