wasmworker 0.4.0

Dispatching tasks to a WebWorker without `SharedArrayBuffers`.
Documentation
use js_sys::wasm_bindgen::JsValue;
use thiserror::Error;

/// This error is returned when a web worker has been configured with a
/// maximum number of tasks to be queued and one of the `try_run` methods
/// is called.
#[derive(Debug, Error)]
#[error("WebWorker capacity reached")]
pub struct Full;

/// This error is returned during the creation of a new web worker.
/// It covers generic errors in the actual creation and import errors
/// during the initialization.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum InitError {
    /// This error covers errors during the `new Worker()` command.
    #[error("WebWorker creation error: {0:?}")]
    WebWorkerCreation(JsValue),
    /// This error signals that the [`crate::WebWorker`] has been initialized with
    /// an invalid path. The path should point to the glue file generated by wasm-bindgen.
    #[error("WebWorker module loading error: {0:?}")]
    WebWorkerModuleLoading(String),
    /// This error covers errors during the `new MessageChannel()` command.
    #[error("Channel creation error: {0:?}")]
    ChannelCreation(JsValue),
}