From 95653cde846897b4cf84ccf7cb6897de13a24994 Mon Sep 17 00:00:00 2001 From: p11 Date: Thu, 29 May 2025 20:19:04 +0200 Subject: [PATCH] Moved struct definitions up --- src/main.rs | 56 ++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/main.rs b/src/main.rs index 304c627..88dcced 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,6 +31,34 @@ mod vn; use request::Request; use vn::render_novel; +#[derive(Clone)] +struct Comment { + name: Box, + text: Box, +} + +#[derive(Default)] +struct SiteInfo { + comments: Mutex>, + visits: AtomicUsize, + up: AtomicUsize, + down: AtomicUsize, +} + +#[derive(Default)] +struct Context { + infos: HashMap, Arc>, +} + +#[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 { let Ok(path) = env::current_dir() else { eprintln!("Current directory does not exist!"); @@ -105,20 +133,6 @@ fn fail(mut stream: TcpStream) { let _ = writeln!(stream, "Page not found!"); } -#[derive(Clone)] -struct Comment { - name: Box, - text: Box, -} - -#[derive(Default)] -struct SiteInfo { - comments: Mutex>, - visits: AtomicUsize, - up: AtomicUsize, - down: AtomicUsize, -} - impl ToStream for SiteInfo { fn to_stream(&self, stream: &mut W) -> Result<()> { let Ok(comments) = self.comments.lock() else { @@ -177,11 +191,6 @@ impl FromStream for SiteInfo { } } -#[derive(Default)] -struct Context { - infos: HashMap, Arc>, -} - fn handle_connection( context: Arc>, 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( info: Arc, mut stream: TcpStream,