When using jpeg-decoder in a multi-threaded application, or with a library like anyhow, it is desirable to have the error type meet the Error + Send + Sync + 'static bounds. jpeg_decoder::Error has an Internal(Box<dyn std::Error>) variant that prevented the type from being Send and Sync.
The only use of this variant was for errors related to communicating with the worker thread. SendError contains the object that failed to be sent on the channel, which made it not Sync. SendError doesn't seem to be designed to be propagated with ? -- returning this internal message object is not useful to expose to the caller of jpeg_decoder.
Those channel related errors can only occur if the worker thread panics or otherwise exits prematurely. This would be a library bug, not something caused by user input, so it seems like the kind of fault that should just be a panic rather than a variant of the Error type.
Because Error::Internal is a part of the public API, and crates like image match on it, this commit leaves it in place but unused, just adding the necessary trait bounds. It can be removed in version 0.2.
When using jpeg-decoder in a multi-threaded application, or with a library like
anyhow
, it is desirable to have the error type meet theError + Send + Sync + 'static
bounds.jpeg_decoder::Error
has anInternal(Box<dyn std::Error>)
variant that prevented the type from beingSend
andSync
.The only use of this variant was for errors related to communicating with the worker thread.
SendError
contains the object that failed to be sent on the channel, which made it notSync
.SendError
doesn't seem to be designed to be propagated with?
-- returning this internal message object is not useful to expose to the caller ofjpeg_decoder
.Those channel related errors can only occur if the worker thread panics or otherwise exits prematurely. This would be a library bug, not something caused by user input, so it seems like the kind of fault that should just be a panic rather than a variant of the
Error
type.Because
Error::Internal
is a part of the public API, and crates likeimage
match on it, this commit leaves it in place but unused, just adding the necessary trait bounds. It can be removed in version 0.2.