free-rusty-maker/src/lib.rs

39 lines
1.1 KiB
Rust
Raw Normal View History

2018-10-02 14:12:52 +02:00
#![warn(missing_docs)]
//! This crates contains the (future) rusty game.
2019-03-30 13:34:09 +01:00
use std::{io, fmt, result};
2018-10-02 21:48:19 +02:00
/// This module contains all the tools needed for the game.
pub mod engine;
2019-03-30 13:34:09 +01:00
/// This is the error type of this library.
#[derive(Debug)]
pub enum Error {
/// An error occured while trying to save a file.
Save(io::Error),
/// An error occured while trying to load a file.
Load(io::Error),
/// An error occured while encoding a file.
Encoding(bincode::Error),
/// An error occured while decoding a file.
Decoding(bincode::Error),
}
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::Save(ref e) => write!(fmt, "couldn't save file: {}", e),
Error::Load(ref e) => write!(fmt, "couldn't load file: {}", e),
Error::Encoding(ref e) => write!(fmt, "couldn't encode file: {}", e),
Error::Decoding(ref e) => write!(fmt, "couldn't decode file: {}", e),
}
}
}
/// This is the result type of this library.
type Result<T> = result::Result<T, Error>;