43 lines
1.1 KiB
Rust
43 lines
1.1 KiB
Rust
/*
|
|
* Copyright (c) 2023 Emma Tebibyte <emma@tebibyte.media>
|
|
* SPDX-License-Identifier: LGPL-3.0-or-later
|
|
*
|
|
* This file is part of yacexits.
|
|
*
|
|
* Yacexits is free software: you can redistribute it and/or modify it under the
|
|
* terms of the GNU Lesser General Public License as published by the Free
|
|
* Software Foundation, either version 3 of the License, or (at your option) any
|
|
* later version.
|
|
*
|
|
* Yacexits is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
|
* details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with yacexits. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
use alloc::string::String;
|
|
|
|
#[allow(dead_code)]
|
|
pub struct YacError {
|
|
code: u32,
|
|
message: String,
|
|
}
|
|
|
|
pub trait Shave {
|
|
fn code(&self) -> u32;
|
|
|
|
fn message(&self) -> String;
|
|
}
|
|
|
|
impl<T: Shave> From<T> for YacError {
|
|
fn from(err: T) -> Self {
|
|
let message = err.message();
|
|
let code = err.code();
|
|
let out = YacError { message, code };
|
|
out
|
|
}
|
|
}
|