Commit ee2aabd
committed
Make
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.Error Send + Sync + 'static1 parent 08fad3d commit ee2aabd
2 files changed
+5
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
5 | | - | |
6 | 4 | | |
7 | 5 | | |
8 | 6 | | |
| |||
41 | 39 | | |
42 | 40 | | |
43 | 41 | | |
44 | | - | |
| 42 | + | |
45 | 43 | | |
46 | 44 | | |
47 | 45 | | |
| |||
79 | 77 | | |
80 | 78 | | |
81 | 79 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
| 50 | + | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
0 commit comments