hyperlane_techempower 0.4.3

A lightweight, high-performance, and cross-platform Rust HTTP server library built on Tokio. It simplifies modern web service development by providing built-in support for middleware, WebSocket, Server-Sent Events (SSE), and raw TCP communication. With a unified and ergonomic API across Windows, Linux, and MacOS, it enables developers to build robust, scalable, and event-driven network applications with minimal overhead and maximum flexibility.
use super::*;

#[inline(always)]
pub(crate) fn get_thread_count() -> usize {
    num_cpus::get().max(1)
}

pub(crate) fn escape_html(input: &str) -> String {
    let mut result: String = String::new();
    for ch in input.chars() {
        match ch {
            '<' => result.push_str("&lt;"),
            '>' => result.push_str("&gt;"),
            '&' => result.push_str("&amp;"),
            '"' => result.push_str("&quot;"),
            '\'' => result.push_str("&#39;"),
            _ => result.push(ch),
        }
    }
    result
}

pub(crate) fn get_random_id() -> Queries {
    let mut rng: SmallRng = SmallRng::from_rng(&mut rng());
    let random_id: u32 = rng.random_range(1..RANDOM_MAX_ADD_ONE);
    random_id as Queries
}