Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
1.4 kB · 60 lines
Rust
at sans-io
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061use std::error::Error;use std::fmt::{Display, Formatter};use std::io;
#[derive(Debug)]pub enum LoadErr { CantReadFile, Invalid, BufferTooShort, IO(io::Error),}
impl From<io::Error> for LoadErr { fn from(err: io::Error) -> Self { if err.kind() == io::ErrorKind::UnexpectedEof { Self::BufferTooShort } else { Self::IO(err) } }}
impl Display for LoadErr { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "{self:?}") }}
impl Error for LoadErr {}
// This should be a different enum per part of file. Either return a list of these or take a callback// TODO: https://users.rust-lang.org/t/validation-monad/117894/6//// load was partially successful. These are the defects that are in the now loaded project// #[derive(Debug, Clone, Copy)]// #[non_exhaustive]// pub enum LoadDefect {// /// deletes the effect// UnknownEffect,// /// replaced with empty text// InvalidText,// /// tries to replace with a sane default value// OutOfBoundsValue,// /// skips loading of the pointed to value// OutOfBoundsPtr,// }
#[derive(Debug)]pub enum LoadErr2 { CantReadFile, Invalid, BufferTooShort,}impl Display for LoadErr2 { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "{self:?}") }}
impl Error for LoadErr2 {}