Changed to using private constructor rather than From<> JpegDecoderError
This commit is contained in:
1 parent
b1cd459330
commit
a733ff13d9
1 file changed
+17
-8
+17
-8
@@ -4,6 +4,7 @@ use std::fmt::Display;
|
|||||||
use std::io;
|
use std::io;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::string;
|
use std::string;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use jpeg::UnsupportedFeature;
|
use jpeg::UnsupportedFeature;
|
||||||
|
|
||||||
@@ -123,7 +124,7 @@ impl fmt::Display for TiffFormatError {
|
|||||||
RequiredTagEmpty(ref val) => write!(fmt, "Required tag {:?} was empty.", val),
|
RequiredTagEmpty(ref val) => write!(fmt, "Required tag {:?} was empty.", val),
|
||||||
StripTileTagConflict => write!(fmt, "File should contain either (StripByteCounts and StripOffsets) or (TileByteCounts and TileOffsets), other combination was found."),
|
StripTileTagConflict => write!(fmt, "File should contain either (StripByteCounts and StripOffsets) or (TileByteCounts and TileOffsets), other combination was found."),
|
||||||
CycleInOffsets => write!(fmt, "File contained a cycle in the list of IFDs"),
|
CycleInOffsets => write!(fmt, "File contained a cycle in the list of IFDs"),
|
||||||
JpegDecoder(error) => write!(fmt, "{}", error),
|
JpegDecoder(ref error) => write!(fmt, "{}", error),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -327,14 +328,22 @@ impl From<LzwError> for TiffError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone)]
|
||||||
struct JpegDecoderError {
|
pub struct JpegDecoderError {
|
||||||
inner: jpeg::Error,
|
inner: Arc<jpeg::Error>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<jpeg::Error> for JpegDecoderError {
|
impl JpegDecoderError {
|
||||||
fn from(error: jpeg::Error) -> Self {
|
fn new(error: jpeg::Error) -> Self {
|
||||||
Self { inner: error }
|
Self {
|
||||||
|
inner: Arc::new(error),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq for JpegDecoderError {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
Arc::ptr_eq(&self.inner, &other.inner)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +361,7 @@ impl From<JpegDecoderError> for TiffError {
|
|||||||
|
|
||||||
impl From<jpeg::Error> for TiffError {
|
impl From<jpeg::Error> for TiffError {
|
||||||
fn from(error: jpeg::Error) -> Self {
|
fn from(error: jpeg::Error) -> Self {
|
||||||
JpegDecoderError::from(error).into()
|
JpegDecoderError::new(error).into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user