basic file layout

This commit is contained in:
some body 2021-09-16 13:55:05 -05:00
parent 6f8e28826e
commit e399e302c4
5 changed files with 80 additions and 0 deletions

12
Cargo.toml Normal file
View File

@ -0,0 +1,12 @@
[package]
name = "Rircd"
version = "0.1.0"
edition = "2018"
[dependencies]
eyre = "*"
tokio = { version = "*", features = ["full"] }
async-trait = "*"
futures = "0.3.17"

8
src/endpoint.rs Normal file
View File

@ -0,0 +1,8 @@
use async_trait::async_trait;
#[async_trait]
pub trait Endpoint {
fn name(&self) -> String;
}

16
src/event.rs Normal file
View File

@ -0,0 +1,16 @@
use tokio::sync::oneshot;
use eyre::Result;
enum InternalEvent {
}
enum EventKind {
Message,
Internal(InternalEvent),
}
struct Event {
kind: EventKind,
result_channel: oneshot::Receiver<Result<()>>,
}

16
src/main.rs Normal file
View File

@ -0,0 +1,16 @@
use eyre::Result;
mod endpoint;
mod state;
mod event;
use state::RircdState;
//TODO maybe spawn the reactor later on with
//user provided parameters (cores/[st/mt])
#[tokio::main]
async fn main() -> Result<()> {
let s = RircdState::new()?;
Ok(())
}

28
src/state.rs Normal file
View File

@ -0,0 +1,28 @@
use eyre::Result;
use std::time::Instant;
use std::sync::Arc;
use crate::endpoint::Endpoint;
pub struct RircdState {
endpoints: Vec<Arc<dyn Endpoint>>,
//to determine program runtime
creation_timestamp: Option<Instant>,
plainlog: Option<()>,
sqlite_log: Option<()>,
postgres_log: Option<()>,
}
impl RircdState {
pub fn new() -> Result<Self> {
//TODO impl
Ok(RircdState {
endpoints: vec![],
creation_timestamp: Some(Instant::now()),
plainlog: None,
sqlite_log: None,
postgres_log: None,
})
}
}