mirror of
https://github.com/Zenithsiz/dcb.git
synced 2026-02-08 19:34:27 +00:00
move warning and errors now implement std::error::Error.
`From` / `Into` implementations for `Data` and `u64` are now done using `derive_more`.
This commit is contained in:
@@ -111,19 +111,17 @@ impl Validatable for Move {
|
||||
}
|
||||
|
||||
/// All warnings for [`Move`] validation
|
||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||
#[derive(derive_more::Display)]
|
||||
#[derive(PartialEq, Eq, Clone, Debug, thiserror::Error)]
|
||||
pub enum ValidationWarning {
|
||||
/// Power is not a multiple of 10
|
||||
#[display(fmt = "Power is not a multiple of 10.")]
|
||||
#[error("Power is not a multiple of 10.")]
|
||||
PowerMultiple10,
|
||||
}
|
||||
|
||||
/// All errors for [`Move`] validation
|
||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||
#[derive(derive_more::Display)]
|
||||
#[derive(PartialEq, Eq, Clone, Debug, thiserror::Error)]
|
||||
pub enum ValidationError {
|
||||
/// Name length
|
||||
#[display(fmt = "Name is too long. Must be at most 21 characters")]
|
||||
#[error("Name is too long. Must be at most 21 characters")]
|
||||
NameTooLong,
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ use crate::{
|
||||
/// All addresses of type `Data` will represent the position
|
||||
/// within *only* the data sections on the file.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[derive(derive_more::From, derive_more::Into)]
|
||||
pub struct Data(u64);
|
||||
|
||||
impl Data {
|
||||
@@ -68,18 +69,6 @@ impl Data {
|
||||
}
|
||||
}
|
||||
|
||||
// Conversions from and into u64
|
||||
impl From<Data> for u64 {
|
||||
fn from(address: Data) -> Self {
|
||||
address.0
|
||||
}
|
||||
}
|
||||
impl From<u64> for Data {
|
||||
fn from(address: u64) -> Self {
|
||||
Self(address)
|
||||
}
|
||||
}
|
||||
|
||||
// Data + Offset
|
||||
impl std::ops::Add<i64> for Data {
|
||||
type Output = Self;
|
||||
|
||||
Reference in New Issue
Block a user