operation_queue/error.rs
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5use async_channel::SendError;
6use thiserror::Error;
7
8use crate::ErasedQueuedOperation;
9
10/// An error returned from the queue.
11#[derive(Debug, Error)]
12pub enum Error {
13 #[error("the queue has been stopped and cannot be started again")]
14 Stopped,
15
16 #[error("could not send operation to queue: sending into a closed channel")]
17 Sender,
18}
19
20impl From<SendError<Box<dyn ErasedQueuedOperation>>> for Error {
21 // `SendError` is only returned in one case: the channel is closed.
22 fn from(_: SendError<Box<dyn ErasedQueuedOperation>>) -> Self {
23 Error::Sender
24 }
25}