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

actioninja / refpack-rs / 6689328355

30 Oct 2023 06:54AM UTC coverage: 89.345% (-3.0%) from 92.374%
6689328355

Pull #6

github

web-flow
Merge 6f3e6b894 into f55f4d390
Pull Request #6: Demoded controls

294 of 294 new or added lines in 7 files covered. (100.0%)

914 of 1023 relevant lines covered (89.35%)

154499.47 hits per line

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

52.0
/src/error.rs
1
////////////////////////////////////////////////////////////////////////////////
2
// This Source Code Form is subject to the terms of the Mozilla Public         /
3
// License, v. 2.0. If a copy of the MPL was not distributed with this         /
4
// file, You can obtain one at https://mozilla.org/MPL/2.0/.                   /
5
//                                                                             /
6
////////////////////////////////////////////////////////////////////////////////
7

8
use std::fmt::{Display, Formatter};
9

10
use crate::data::DecodeError;
11

12
/// Possible errors returned by compression and decompression functions
13
#[derive(Debug)]
×
14
pub enum Error {
15
    /// Error for when no input is provided to a compressor function
16
    EmptyInput,
17
    /// Error that occurs when a flag was set in the header flags that is not
18
    /// supported
19
    ///
20
    /// ### Fields
21
    /// - u8: What was read instead of the expected flags
22
    BadFlags(u8),
23
    /// Error indicating that the header failed to read the magic where it
24
    /// expected it. Location depends on the exact implementation.
25
    ///
26
    /// ### Fields
27
    /// - u8: What was read instead of the magic value
28
    BadMagic(u8),
29
    /// Indicates that an invalid operation occurred while attempting to decode
30
    /// a control. This normally indicates invalid or corrupted data.
31
    ///
32
    /// See [DecodeError] for further details on types of errors that can occur.
33
    ControlError { error: DecodeError, position: usize },
34
    /// Generic IO Error wrapper for when a generic IO error of some sort occurs
35
    /// in relation to the readers and writers.
36
    Io(std::io::Error),
37
}
38

39
impl From<std::io::Error> for Error {
40
    fn from(value: std::io::Error) -> Self {
×
41
        Self::Io(value)
×
42
    }
×
43
}
44

45
impl Display for Error {
46
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
8✔
47
        match self {
8✔
48
            Error::EmptyInput => {
49
                write!(f, "No input provided to compression")
×
50
            }
51
            Error::BadFlags(flags) => {
4✔
52
                write!(
4✔
53
                    f,
4✔
54
                    "Unknown flag was set in compression header `{flags:08b}`"
4✔
55
                )
4✔
56
            }
57
            Error::BadMagic(magic) => {
4✔
58
                write!(
4✔
59
                    f,
4✔
60
                    "Invalid magic number at compression header `{magic:#04X}`"
4✔
61
                )
4✔
62
            }
63
            Error::ControlError { position, error } => {
×
64
                write!(
×
65
                    f,
×
66
                    "Error occured while decoding control block at position `{position}`:\n{error}"
×
67
                )
×
68
            }
69
            Error::Io(err) => {
×
70
                write!(f, "IO Error: {err}")
×
71
            }
72
        }
73
    }
8✔
74
}
75

76
impl std::error::Error for Error {}
77

78
/// Wrapper for Result specified to [RefPackError]
79
pub type Result<T> = std::result::Result<T, Error>;
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