use bevy::prelude::*;
#[derive(Component, Clone, Copy, Debug)]
pub struct StatusCode(pub(crate) u16);
impl StatusCode {
#[inline]
pub const fn new(code: u16) -> Self {
Self(code)
}
#[inline]
pub const fn code(&self) -> u16 {
self.0
}
#[inline]
pub const fn is_informational(&self) -> bool {
100 <= self.0 && self.0 < 200
}
#[inline]
pub const fn is_successful(&self) -> bool {
200 <= self.0 && self.0 < 300
}
#[inline]
pub const fn is_redirection(&self) -> bool {
300 <= self.0 && self.0 < 400
}
#[inline]
pub const fn is_client_error(&self) -> bool {
400 <= self.0 && self.0 < 500
}
#[inline]
pub const fn is_server_error(&self) -> bool {
500 <= self.0 && self.0 < 600
}
#[inline]
pub const fn is_invalid(&self) -> bool {
self.0 < 100 || self.0 > 599
}
}