• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

royaltm / rust-delharc / 8115191789

01 Mar 2024 05:50PM UTC coverage: 89.295% (+1.4%) from 87.907%
8115191789

Pull #6

github

web-flow
Merge a2b66817c into 8bad87b9f
Pull Request #6: no-std

289 of 343 new or added lines in 16 files covered. (84.26%)

1 existing line in 1 file now uncovered.

1977 of 2214 relevant lines covered (89.3%)

1662119.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.17
/src/error.rs
1
use core::fmt;
2
#[cfg(feature = "std")]
3
use std::io;
4
use crate::stub_io::Read;
5

6
pub type LhaResult<T, R> = Result<T, LhaError<<R as Read>::Error>>;
7

8
#[derive(Debug, PartialEq, Eq)]
9
#[non_exhaustive]
10
pub enum LhaError<E> {
11
    /// I/O error
12
    Io(E),
13
    /// Error parsing LHA header
14
    HeaderParse(&'static str),
15
    /// Error decompressing file
16
    Decompress(&'static str),
17
    /// Checksum error
18
    Checksum(&'static str),
19
}
20

21
impl<E: fmt::Display> fmt::Display for LhaError<E> {
22
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1✔
23
        use LhaError::*;
1✔
24
        match self {
1✔
NEW
25
            Io(e) => e.fmt(f),
×
26
            HeaderParse(e) => write!(f, "while parsing header: {}", e),
1✔
NEW
27
            Decompress(e) => write!(f, "while decompressing: {}", e),
×
NEW
28
            Checksum(e) => write!(f, "checksum mismatch: {}", e),
×
29
        }
30
    }
1✔
31
}
32

33
#[cfg(feature = "std")]
34
impl<E: std::error::Error + 'static> std::error::Error for LhaError<E> {
NEW
35
    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
×
NEW
36
        use LhaError::*;
×
NEW
37
        match self {
×
NEW
38
            Io(e) => Some(e),
×
NEW
39
            _ => None
×
40
        }
NEW
41
    }
×
42
}
43

44
#[cfg(feature = "std")]
45
impl From<LhaError<io::Error>> for io::Error {
46
    fn from(err: LhaError<io::Error>) -> Self {
738✔
47
        use LhaError::*;
738✔
48
        use io::{Error, ErrorKind};
738✔
49
        match err {
738✔
50
            Io(e) => e,
24✔
NEW
51
            HeaderParse(e) => Error::new(ErrorKind::InvalidData, e),
×
52
            Decompress(e) => Error::new(ErrorKind::InvalidData, e),
714✔
NEW
53
            Checksum(e) => Error::new(ErrorKind::InvalidData, e),
×
54
        }
55
    }
738✔
56
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc