rust-web-server 18.8.2

Single-binary web server and reverse proxy: automatic HTTPS (Let's Encrypt), HTTP/1.1, HTTP/2 and HTTP/3, load balancing, auth and rate limiting, configured in one TOML file. Also a Rust library: routing, middleware, MCP server, ORM, background jobs. No hyper, no Tower; HTTP/2 and HTTP/3 framing via h2 and quinn.
Documentation
//! [`Null`]: a value representing JSON `null`, with `FromStr` (failing with
//! [`ParseNullError`]), `Display`, `Clone`, `Debug`, `PartialEq` and
//! [`New`](crate::core::New).

#[cfg(test)]
mod tests;

use std::fmt::{Debug, Display, Formatter};
use std::str::FromStr;
use crate::core::New;

pub const NULL: &'static Null = &Null{};

pub struct Null {}

pub struct ParseNullError {
    pub message: String
}

impl Debug for ParseNullError {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.message)
    }
}

impl Display for Null {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        f.write_str("null")
    }
}

impl PartialEq for Null {
    fn eq(&self, _other: &Self) -> bool {
        true
    }
}

impl Debug for Null {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        f.write_str("null")
    }
}

impl New for Null {
    fn new() -> Self {
        Null{}
    }
}

impl Clone for Null {
    fn clone(&self) -> Self {
        Null::new()
    }
}

impl FromStr for Null {
    type Err = ParseNullError;

    fn from_str(null: &str) -> Result<Self, Self::Err> {
        if null.trim() != "null" {
            let message = format!("error parsing null: {}", null);
            return Err(ParseNullError { message })
        }
        Ok(Null::new())
    }
}