protoc-gen-rust-temporal 0.1.1

protoc plugin that emits a typed Rust Temporal client from temporal.v1.* annotated services
Documentation
// Code generated by protoc-gen-rust-temporal. DO NOT EDIT.
// source: input.proto

#[allow(clippy::all, unused_imports, dead_code)]
pub mod empty_v1_nop_service_temporal {
    use anyhow::Result;
    use std::time::Duration;
    use crate::temporal_runtime;
    use crate::empty::v1::*;

    pub const TICK_WORKFLOW_NAME: &str = "empty.v1.NopService/Tick";
    pub const TICK_TASK_QUEUE: &str = "nop";

    pub struct NopServiceClient {
        client: temporal_runtime::TemporalClient,
    }

    impl NopServiceClient {
        pub fn new(client: temporal_runtime::TemporalClient) -> Self {
            Self { client }
        }

        pub fn inner(&self) -> &temporal_runtime::TemporalClient {
            &self.client
        }

        /// Start a new `empty.v1.NopService/Tick` workflow.
        pub async fn tick(
            &self,
            opts: TickStartOptions,
        ) -> Result<TickHandle> {
            let workflow_id = opts.workflow_id.unwrap_or_else(|| {
                temporal_runtime::random_workflow_id()
            });
            let task_queue = opts.task_queue.unwrap_or_else(|| "nop".to_string());
            let inner = temporal_runtime::start_workflow_proto_empty(
                &self.client,
                TICK_WORKFLOW_NAME,
                &workflow_id,
                &task_queue,
                opts.id_reuse_policy,
                opts.execution_timeout,
                opts.run_timeout,
                opts.task_timeout,
            ).await?;
            Ok(TickHandle { inner })
        }

        /// Attach to a running `empty.v1.NopService/Tick` workflow by id.
        pub fn tick_handle(&self, workflow_id: impl Into<String>) -> TickHandle {
            TickHandle {
                inner: temporal_runtime::attach_handle(&self.client, workflow_id.into()),
            }
        }

    }

    #[derive(Debug, Default, Clone)]
    pub struct TickStartOptions {
        pub workflow_id: Option<String>,
        pub task_queue: Option<String>,
        pub id_reuse_policy: Option<temporal_runtime::WorkflowIdReusePolicy>,
        pub execution_timeout: Option<Duration>,
        pub run_timeout: Option<Duration>,
        pub task_timeout: Option<Duration>,
    }

    pub struct TickHandle {
        inner: temporal_runtime::WorkflowHandle,
    }

    impl TickHandle {
        pub fn workflow_id(&self) -> &str {
            self.inner.workflow_id()
        }

        /// Wait for the workflow to complete and return its output.
        pub async fn result(&self) -> Result<()> {
            temporal_runtime::wait_result_unit(&self.inner).await
        }

    }

}