feat: add image fetching

This commit is contained in:
2026-03-20 19:48:18 +01:00
parent fb62111c7f
commit 12388a9908
17 changed files with 2122 additions and 92 deletions

View File

@@ -7,17 +7,18 @@ use std::{
net::{Ipv4Addr, SocketAddr, SocketAddrV4},
};
use serde::{Deserialize, Serialize};
use serde::Deserialize;
use crate::serdes::Group;
use crate::serdes::{DatabasePaths, Group};
#[derive(Debug, Default, Serialize, Deserialize)]
#[derive(Debug, Default, Deserialize)]
#[serde(default)]
pub struct Unix {
pub groups: Vec<Group>,
pub magic_paths: DatabasePaths,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Deserialize)]
#[serde(default)]
pub struct Server {
pub listen: SocketAddr,
@@ -30,7 +31,7 @@ impl Default for Server {
}
}
#[derive(Debug, Default, Serialize, Deserialize)]
#[derive(Debug, Default, Deserialize)]
#[serde(default)]
pub struct Config {
pub unix: Unix,
@@ -50,12 +51,14 @@ impl Config {
/// # Errors
///
/// For IO errors reading the file or parsing errors.
///
/// # Panics
///
/// If file's u64 length might not fit in memory.
pub fn from_toml_file(f: &mut File) -> Result<Self, ConfigParseError> {
let mut buf = Vec::new();
if let Ok(len) = f.stream_len() {
// There's no way a config file passes machine's memory limitations
#[allow(clippy::cast_possible_truncation)]
buf.reserve_exact(len as usize);
buf.reserve_exact(len.try_into().expect("file's u64 len to fit in memory"));
}
f.read_to_end(&mut buf)?;