neco-server-core 0.1.0

core http primitives for neco-server
Documentation
/// Minimal HTTP status code wrapper.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct StatusCode(u16);

impl StatusCode {
    /// 200 OK
    pub const OK: Self = Self(200);
    /// 400 Bad Request
    pub const BAD_REQUEST: Self = Self(400);
    /// 401 Unauthorized
    pub const UNAUTHORIZED: Self = Self(401);
    /// 404 Not Found
    pub const NOT_FOUND: Self = Self(404);
    /// 405 Method Not Allowed
    pub const METHOD_NOT_ALLOWED: Self = Self(405);
    /// 500 Internal Server Error
    pub const INTERNAL_SERVER_ERROR: Self = Self(500);

    /// Creates a status code wrapper from a raw value.
    pub const fn from_u16(value: u16) -> Self {
        Self(value)
    }

    /// Returns the raw numeric value.
    pub const fn as_u16(self) -> u16 {
        self.0
    }
}