ocl_stream/utils/
result.rs

1/*
2 * opencl stream executor
3 * Copyright (C) 2021 trivernis
4 * See LICENSE for more information
5 */
6
7use crossbeam_channel::RecvError;
8use crossbeam_channel::SendError;
9use std::error::Error;
10use thiserror::Error;
11
12pub type OCLStreamResult<T> = Result<T, OCLStreamError>;
13
14#[derive(Error, Debug)]
15pub enum OCLStreamError {
16    #[error("OpenCL Error {0}")]
17    OCLError(String),
18
19    #[error("Stream Receive Error")]
20    RecvError(#[from] RecvError),
21
22    #[error("Stream Send Error {0:?}")]
23    SendError(#[from] Box<dyn Error + Send + Sync>),
24}
25
26impl From<ocl::Error> for OCLStreamError {
27    fn from(e: ocl::Error) -> Self {
28        Self::OCLError(format!("{}", e))
29    }
30}
31
32impl<T: 'static> From<SendError<T>> for OCLStreamError
33where
34    T: Send + Sync,
35{
36    fn from(e: SendError<T>) -> Self {
37        Self::SendError(Box::new(e))
38    }
39}