gwasm-api 0.1.1

gWasm API for Rust apps
Documentation
//! Errors that can be returned by the library
use actix::MailboxError;
use std::io;
use tokio::timer;

/// Enum wrapping all possible errors that can be generated by the library
#[derive(Debug, thiserror::Error)]
pub enum Error {
    /// Wraps actix's `MailboxError` error
    #[error("internal gWasm API error: {0}")]
    MailboxError(#[from] MailboxError),

    /// Wraps tokio's `timer::Error` error
    #[error("internal gWasm API error: {0}")]
    TimerError(#[from] timer::Error),

    /// Wraps libstd's `std::io::Error` error
    #[error("internal gWasm API error: {0}")]
    IOError(#[from] io::Error),

    /// Wraps Golem's `actix_wamp::Error` error
    #[error("internal Golem error: {0}")]
    WampError(actix_wamp::Error),

    /// Wraps Golem RPC's `golem_rpc_api::Error` error
    #[error("internal Golem error: {0}")]
    GolemRPCError(golem_rpc_api::Error),

    /// Wraps `tokio_ctrlc_error::KeyboardInterrupt` which is used to handle
    /// Ctrl-C interrupt event for the lib's client
    #[error("received Ctrl-C interrupt")]
    KeyboardInterrupt(tokio_ctrlc_error::KeyboardInterrupt),

    /// Wraps other `tokio_ctrlc_error::IoError` type errors
    #[error("internal gWasm API error: {0}")]
    CtrlcError(tokio_ctrlc_error::IoError),

    /// Wraps `chrono::ParseError` error
    #[error("error parsing Timeout value: {0}")]
    ChronoError(#[from] chrono::ParseError),

    /// Error generated when trying to create a zero [`Timeout`](../timeout/struct.Timeout.html)
    /// value for a Golem Task
    #[error("zero timeout \"00:00:00\" is forbidden")]
    ZeroTimeoutError,

    /// Error when no TaskInfo is received when polling for task progress
    /// in [`poll_task_progress`](../golem/fn.poll_task_progress.html)
    #[error("empty TaskInfo received from Golem")]
    EmptyTaskInfo,

    /// Error when no progress can be extracted from TaskInfo
    #[error("empty progress in TaskInfo")]
    EmptyProgress,

    /// Error when gWasm task was aborted externally
    #[error("task aborted externally")]
    TaskAborted,

    /// Error when gWasm task timed out
    #[error("task timed out")]
    TaskTimedOut,
}

impl From<actix_wamp::Error> for Error {
    fn from(err: actix_wamp::Error) -> Self {
        Error::WampError(err)
    }
}

impl From<golem_rpc_api::Error> for Error {
    fn from(err: golem_rpc_api::Error) -> Self {
        Error::GolemRPCError(err)
    }
}

impl From<tokio_ctrlc_error::IoError> for Error {
    fn from(err: tokio_ctrlc_error::IoError) -> Self {
        Error::CtrlcError(err)
    }
}

impl From<tokio_ctrlc_error::KeyboardInterrupt> for Error {
    fn from(err: tokio_ctrlc_error::KeyboardInterrupt) -> Self {
        Error::KeyboardInterrupt(err)
    }
}