Simplify default Result generics.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-07-08 12:08:13 +00:00
parent 8244d78cb2
commit ae707ab465
42 changed files with 95 additions and 115 deletions

View File

@@ -321,7 +321,7 @@ fn warn_unknown_key(config: &Config) {
/// Checks the presence of the `address` and `unix_socket_path` keys in the
/// raw_config, exiting the process if both keys were detected.
pub(super) fn is_dual_listening(raw_config: &Figment) -> Result<()> {
pub(super) fn is_dual_listening(raw_config: &Figment) -> Result {
let contains_address = raw_config.contains("address");
let contains_unix_socket = raw_config.contains("unix_socket_path");
if contains_address && contains_unix_socket {

View File

@@ -78,7 +78,7 @@ fn init_features() -> Result<Vec<String>> {
Ok(features)
}
fn append_features(features: &mut Vec<String>, manifest: &str) -> Result<()> {
fn append_features(features: &mut Vec<String>, manifest: &str) -> Result {
let manifest = Manifest::from_str(manifest)?;
features.extend(manifest.features.keys().cloned());

View File

@@ -22,7 +22,7 @@ where
pub fn fmt<F, S>(fun: F, out: Arc<Mutex<S>>) -> Box<Closure>
where
F: Fn(&mut S, &Level, &str, &str) -> Result<()> + Send + Sync + Copy + 'static,
F: Fn(&mut S, &Level, &str, &str) -> Result + Send + Sync + Copy + 'static,
S: std::fmt::Write + Send + 'static,
{
Box::new(move |data| call(fun, &mut *out.lock().expect("locked"), &data))
@@ -30,7 +30,7 @@ where
fn call<F, S>(fun: F, out: &mut S, data: &Data<'_>)
where
F: Fn(&mut S, &Level, &str, &str) -> Result<()>,
F: Fn(&mut S, &Level, &str, &str) -> Result,
S: std::fmt::Write,
{
fun(out, &data.level(), data.span_name(), data.message()).expect("log line appended");

View File

@@ -3,7 +3,7 @@ use std::fmt::Write;
use super::{Level, color};
use crate::Result;
pub fn html<S>(out: &mut S, level: &Level, span: &str, msg: &str) -> Result<()>
pub fn html<S>(out: &mut S, level: &Level, span: &str, msg: &str) -> Result
where
S: Write + ?Sized,
{
@@ -18,7 +18,7 @@ where
Ok(())
}
pub fn markdown<S>(out: &mut S, level: &Level, span: &str, msg: &str) -> Result<()>
pub fn markdown<S>(out: &mut S, level: &Level, span: &str, msg: &str) -> Result
where
S: Write + ?Sized,
{
@@ -28,7 +28,7 @@ where
Ok(())
}
pub fn markdown_table<S>(out: &mut S, level: &Level, span: &str, msg: &str) -> Result<()>
pub fn markdown_table<S>(out: &mut S, level: &Level, span: &str, msg: &str) -> Result
where
S: Write + ?Sized,
{
@@ -38,7 +38,7 @@ where
Ok(())
}
pub fn markdown_table_head<S>(out: &mut S) -> Result<()>
pub fn markdown_table_head<S>(out: &mut S) -> Result
where
S: Write + ?Sized,
{

View File

@@ -49,7 +49,7 @@ impl LogLevelReloadHandles {
.insert(name.into(), handle);
}
pub fn reload(&self, new_value: &EnvFilter, names: Option<&[&str]>) -> Result<()> {
pub fn reload(&self, new_value: &EnvFilter, names: Option<&[&str]>) -> Result {
self.handles
.lock()
.expect("locked")

View File

@@ -64,7 +64,7 @@ impl Server {
}
}
pub fn reload(&self) -> Result<()> {
pub fn reload(&self) -> Result {
if cfg!(any(not(tuwunel_mods), not(feature = "tuwunel_mods"))) {
return Err!("Reloading not enabled");
}
@@ -103,7 +103,7 @@ impl Server {
})
}
pub fn signal(&self, sig: &'static str) -> Result<()> {
pub fn signal(&self, sig: &'static str) -> Result {
if let Err(e) = self.signal.send(sig) {
return Err!("Failed to send signal: {e}");
}

View File

@@ -36,7 +36,7 @@ pub(super) fn password(password: &str) -> Result<String> {
.map_err(map_err)
}
pub(super) fn verify_password(password: &str, password_hash: &str) -> Result<()> {
pub(super) fn verify_password(password: &str, password_hash: &str) -> Result {
let password_hash = PasswordHash::new(password_hash).map_err(map_err)?;
ARGON
.get_or_init(init_argon)

View File

@@ -42,7 +42,7 @@ macro_rules! is_format {
#[inline]
pub fn collect_stream<F>(func: F) -> Result<String>
where
F: FnOnce(&mut dyn std::fmt::Write) -> Result<()>,
F: FnOnce(&mut dyn std::fmt::Write) -> Result,
{
let mut out = String::new();
func(&mut out)?;
@@ -63,7 +63,7 @@ pub fn camel_to_snake_string(s: &str) -> String {
#[inline]
#[allow(clippy::unbuffered_bytes)] // these are allocated string utilities, not file I/O utils
pub fn camel_to_snake_case<I, O>(output: &mut O, input: I) -> Result<()>
pub fn camel_to_snake_case<I, O>(output: &mut O, input: I) -> Result
where
I: std::io::Read,
O: std::fmt::Write,