Moved struct definitions up

This commit is contained in:
p11 2025-05-29 20:19:04 +02:00
parent ffc6247cd7
commit 95653cde84

View File

@ -31,6 +31,34 @@ mod vn;
use request::Request;
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 {
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<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 {
fn to_stream<W: Write>(&self, stream: &mut W) -> Result<()> {
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(
context: Arc<Mutex<Context>>,
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<SiteInfo>,
mut stream: TcpStream,