1use crate::parsely_write::ParselyWrite;
2
3pub type ParselyResult<T> = anyhow::Result<T>;
4
5pub trait IntoWritableParselyResult<T> {
10 fn into_parsely_result(self) -> ParselyResult<T>;
11}
12
13impl<T> IntoWritableParselyResult<T> for T
14where
15 T: ParselyWrite,
16{
17 fn into_parsely_result(self) -> ParselyResult<T> {
18 Ok(self)
19 }
20}
21
22impl<T, E> IntoWritableParselyResult<T> for Result<T, E>
23where
24 E: Into<anyhow::Error>,
25{
26 fn into_parsely_result(self) -> ParselyResult<T> {
27 self.map_err(Into::into)
28 }
29}
30
31pub trait IntoParselyResult<T> {
37 fn into_parsely_result_read(self) -> ParselyResult<T>;
38}
39
40impl<T> IntoParselyResult<T> for T {
41 fn into_parsely_result_read(self) -> ParselyResult<T> {
42 Ok(self)
43 }
44}
45
46impl<T, E> IntoParselyResult<T> for Result<T, E>
47where
48 E: Into<anyhow::Error>,
49{
50 fn into_parsely_result_read(self) -> ParselyResult<T> {
51 self.map_err(Into::into)
52 }
53}