pub struct Code { /* private fields */ }Expand description
Waddling diagnostic code: SEVERITY.COMPONENT.PRIMARY.SEQUENCE
Format: E.CRYPTO.SALT.001
§Examples
use waddling_errors::{Code, Severity};
const ERR: Code = Code::error("CRYPTO", "SALT", 1);
assert_eq!(ERR.code(), "E.CRYPTO.SALT.001");Implementations§
Source§impl Code
impl Code
Sourcepub const fn new(
severity: Severity,
component: &'static str,
primary: &'static str,
sequence: u16,
) -> Self
pub const fn new( severity: Severity, component: &'static str, primary: &'static str, sequence: u16, ) -> Self
Create a new code with explicit severity
§Panics
Panics if sequence > 999, or component/primary length not in 2-12 range
Sourcepub const fn error(
component: &'static str,
primary: &'static str,
sequence: u16,
) -> Self
pub const fn error( component: &'static str, primary: &'static str, sequence: u16, ) -> Self
Create an error code (E)
Sourcepub const fn warning(
component: &'static str,
primary: &'static str,
sequence: u16,
) -> Self
pub const fn warning( component: &'static str, primary: &'static str, sequence: u16, ) -> Self
Create a warning code (W)
Sourcepub const fn critical(
component: &'static str,
primary: &'static str,
sequence: u16,
) -> Self
pub const fn critical( component: &'static str, primary: &'static str, sequence: u16, ) -> Self
Create a critical code (C)
Sourcepub const fn blocked(
component: &'static str,
primary: &'static str,
sequence: u16,
) -> Self
pub const fn blocked( component: &'static str, primary: &'static str, sequence: u16, ) -> Self
Create a blocked code (B)
Sourcepub const fn help(
component: &'static str,
primary: &'static str,
sequence: u16,
) -> Self
pub const fn help( component: &'static str, primary: &'static str, sequence: u16, ) -> Self
Create a help code (H)
Sourcepub const fn success(
component: &'static str,
primary: &'static str,
sequence: u16,
) -> Self
pub const fn success( component: &'static str, primary: &'static str, sequence: u16, ) -> Self
Create a success code (S)
Sourcepub const fn completed(
component: &'static str,
primary: &'static str,
sequence: u16,
) -> Self
pub const fn completed( component: &'static str, primary: &'static str, sequence: u16, ) -> Self
Create a completed code (K)
Sourcepub const fn info(
component: &'static str,
primary: &'static str,
sequence: u16,
) -> Self
pub const fn info( component: &'static str, primary: &'static str, sequence: u16, ) -> Self
Create an info code (I)
Sourcepub const fn trace(
component: &'static str,
primary: &'static str,
sequence: u16,
) -> Self
pub const fn trace( component: &'static str, primary: &'static str, sequence: u16, ) -> Self
Create a trace code (T)
Sourcepub fn write_code(&self, f: &mut impl Write) -> Result
pub fn write_code(&self, f: &mut impl Write) -> Result
Write error code to formatter without allocating
Use in performance-critical paths to avoid String allocation.
Trait Implementations§
impl Copy for Code
impl Eq for Code
impl StructuralPartialEq for Code
Auto Trait Implementations§
impl Freeze for Code
impl RefUnwindSafe for Code
impl Send for Code
impl Sync for Code
impl Unpin for Code
impl UnwindSafe for Code
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more