Skip to main content

tmprl_client/ops/
mod.rs

1//! Typed operations.
2//!
3//! Everything above this crate talks in these types, never in protobuf types. That is what
4//! keeps a `temporalio-client` bump contained: the generated types stop here.
5
6pub mod codec;
7pub mod history;
8pub mod mutate;
9pub mod namespace;
10pub mod schedule;
11pub mod workflow;
12
13#[derive(Debug, thiserror::Error)]
14pub enum OpError {
15    #[error("{operation} failed: {message}")]
16    Rpc {
17        operation: &'static str,
18        code: String,
19        message: String,
20    },
21    /// The codec server is HTTP, not gRPC, so its failures are not `tonic::Status`.
22    #[error("{message}")]
23    Codec { message: String },
24}
25
26impl OpError {
27    pub(crate) fn rpc(operation: &'static str, status: temporalio_client::tonic::Status) -> Self {
28        Self::Rpc {
29            operation,
30            code: format!("{:?}", status.code()),
31            message: status.message().to_string(),
32        }
33    }
34}