Skip to content

Commit

Permalink
Implement Error for DataError
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Jan 24, 2016
1 parent 723cc06 commit ec5c851
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/mem.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use std::error::Error;
use std::fmt;

use libc::c_int;

use {Compression, Flush};
Expand Down Expand Up @@ -32,6 +35,7 @@ pub struct Decompress {

/// Error returned when a decompression object finds that the input stream of
/// bytes was not a valid input stream of bytes.
#[derive(Debug)]
pub struct DataError(());

/// Possible status results of compressing some data or successfully
Expand Down Expand Up @@ -205,3 +209,13 @@ impl Decompress {
}
}
}

impl Error for DataError {
fn description(&self) -> &str { "deflate data error" }
}

impl fmt::Display for DataError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.description().fmt(f)
}
}

0 comments on commit ec5c851

Please sign in to comment.