ligen_core/
prelude.rs

1//! Prelude module with error handling types and others types.
2
3pub(crate) use shrinkwraprs::Shrinkwrap;
4pub use proc_macro2::TokenStream;
5pub use quote::quote;
6pub use quote::TokenStreamExt;
7
8/// Library error.
9#[derive(Debug) ]
10pub enum Error {
11    /// IO errors.
12    IO(std::io::Error),
13    /// JSON errors.
14    JSON(serde_json::Error),
15    /// Misc errors.
16    Message(String),
17}
18
19impl From<&str> for Error {
20    fn from(s: &str) -> Self {
21        Self::Message(s.into())
22    }
23}
24
25impl From<String> for Error {
26    fn from(s: String) -> Self {
27        Self::Message(s)
28    }
29}
30
31impl From<std::io::Error> for Error {
32    fn from(error: std::io::Error) -> Self {
33        Self::IO(error)
34    }
35}
36
37impl From<serde_json::Error> for Error {
38    fn from(error: serde_json::Error) -> Self {
39        Self::JSON(error)
40    }
41}
42
43/// Library result.
44pub type Result<T> = std::result::Result<T, Error>;