#[cfg(feature = "serde")]
#[macro_use]
extern crate serde;
mod enums;
pub use enums::*;
pub mod canifier;
pub mod logger;
pub mod mot;
pub mod pigeon;
use std::fmt;
impl ErrorCode {
#[inline]
pub fn is_ok(self) -> bool {
self == ErrorCode::OK
}
#[inline]
pub fn is_err(self) -> bool {
self != ErrorCode::OK
}
pub fn or(self, err: Self) -> Self {
match self {
ErrorCode::OK => err,
_ => self,
}
}
pub fn into_res(self) -> Result<(), Self> {
match self {
ErrorCode::OK => Ok(()),
_ => Err(self),
}
}
}
impl std::error::Error for ErrorCode {
fn description(&self) -> &str {
"Error in CTRE Phoenix"
}
}
impl fmt::Display for ErrorCode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
}
}
#[cfg(feature = "try_trait")]
impl std::ops::Try for ErrorCode {
type Ok = ();
type Error = Self;
fn into_result(self) -> Result<(), Self> {
match self {
ErrorCode::OK => Ok(()),
_ => Err(self),
}
}
fn from_error(v: Self) -> Self {
v
}
fn from_ok(v: ()) -> Self {
ErrorCode::OK
}
}