Moved struct definitions up
This commit is contained in:
parent
ffc6247cd7
commit
95653cde84
56
src/main.rs
56
src/main.rs
@ -31,6 +31,34 @@ mod vn;
|
|||||||
use request::Request;
|
use request::Request;
|
||||||
use vn::render_novel;
|
use vn::render_novel;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
struct Comment {
|
||||||
|
name: Box<str>,
|
||||||
|
text: Box<str>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
struct SiteInfo {
|
||||||
|
comments: Mutex<Vec<Comment>>,
|
||||||
|
visits: AtomicUsize,
|
||||||
|
up: AtomicUsize,
|
||||||
|
down: AtomicUsize,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
struct Context {
|
||||||
|
infos: HashMap<Box<str>, Arc<SiteInfo>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
struct DocumentPaths<'a> {
|
||||||
|
pk: &'a Path,
|
||||||
|
mld: &'a Path,
|
||||||
|
pki: Option<&'a Path>,
|
||||||
|
audio: Option<&'a Path>,
|
||||||
|
data: &'a Path,
|
||||||
|
}
|
||||||
|
|
||||||
fn main() -> ExitCode {
|
fn main() -> ExitCode {
|
||||||
let Ok(path) = env::current_dir() else {
|
let Ok(path) = env::current_dir() else {
|
||||||
eprintln!("Current directory does not exist!");
|
eprintln!("Current directory does not exist!");
|
||||||
@ -105,20 +133,6 @@ fn fail(mut stream: TcpStream) {
|
|||||||
let _ = writeln!(stream, "Page not found!");
|
let _ = writeln!(stream, "Page not found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
struct Comment {
|
|
||||||
name: Box<str>,
|
|
||||||
text: Box<str>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
struct SiteInfo {
|
|
||||||
comments: Mutex<Vec<Comment>>,
|
|
||||||
visits: AtomicUsize,
|
|
||||||
up: AtomicUsize,
|
|
||||||
down: AtomicUsize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: SizeSettings> ToStream<S> for SiteInfo {
|
impl<S: SizeSettings> ToStream<S> for SiteInfo {
|
||||||
fn to_stream<W: Write>(&self, stream: &mut W) -> Result<()> {
|
fn to_stream<W: Write>(&self, stream: &mut W) -> Result<()> {
|
||||||
let Ok(comments) = self.comments.lock() else {
|
let Ok(comments) = self.comments.lock() else {
|
||||||
@ -177,11 +191,6 @@ impl<S: SizeSettings> FromStream<S> for SiteInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
struct Context {
|
|
||||||
infos: HashMap<Box<str>, Arc<SiteInfo>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_connection(
|
fn handle_connection(
|
||||||
context: Arc<Mutex<Context>>,
|
context: Arc<Mutex<Context>>,
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
@ -432,15 +441,6 @@ fn reply_binary(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
struct DocumentPaths<'a> {
|
|
||||||
pk: &'a Path,
|
|
||||||
mld: &'a Path,
|
|
||||||
pki: Option<&'a Path>,
|
|
||||||
audio: Option<&'a Path>,
|
|
||||||
data: &'a Path,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_relative_connection(
|
fn handle_relative_connection(
|
||||||
info: Arc<SiteInfo>,
|
info: Arc<SiteInfo>,
|
||||||
mut stream: TcpStream,
|
mut stream: TcpStream,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user