index : license-api-rs.git

ascending towards madness

#[derive(Debug)]
pub enum ErrorMsg {
    DatabaseError,
    NoLicensesAvailable,
    InvalidLicenseRequest,
    InvalidLicense,
    LicenseReadError,
}

impl ErrorMsg {
    pub fn as_str(&self) -> &str {
        match *self {
            ErrorMsg::LicenseReadError => "Unable to read license file:",
            ErrorMsg::DatabaseError => "Unable to load or parse license database.",
            ErrorMsg::NoLicensesAvailable => "No licenses found.",
            ErrorMsg::InvalidLicenseRequest => { //TODO: make this not hardcoded
                "Invalid license. use the 'list' or 'list/all' endpoints to see defined licenses."
            }
            ErrorMsg::InvalidLicense => "Invalid license requested:",
        }
    }
}

#[derive(Debug)]
pub enum SuccessMsg {
    DatabaseLoaded,
}

impl SuccessMsg {
    pub fn as_str(&self) -> &str {
        match *self {
            SuccessMsg::DatabaseLoaded => "Database loaded successfully!",
        }
    }
}