spark_sdk/rpc/
mod.rs

1use connections::connection::SparkConnection;
2use spark_protos::{
3    authn::spark_authn_service_client::SparkAuthnServiceClient,
4    spark::spark_service_client::SparkServiceClient,
5};
6use tonic::transport::Channel;
7
8use crate::error::SparkSdkError;
9
10/// Enum representing different types of Spark RPC clients.
11/// Currently only supports TLS with certificate verification disabled.
12#[derive(Clone)]
13pub(crate) enum SparkRpcClient {
14    DefaultConnection(SparkConnection),
15}
16
17impl SparkRpcClient {
18    pub(crate) fn get_new_spark_service_connection(
19        &self,
20    ) -> Result<SparkServiceClient<Channel>, SparkSdkError> {
21        match self {
22            SparkRpcClient::DefaultConnection(client) => {
23                Ok(SparkServiceClient::new(client.channel.clone()))
24            }
25        }
26    }
27
28    pub(crate) fn get_new_spark_authn_service_connection(
29        &self,
30    ) -> Result<SparkAuthnServiceClient<Channel>, SparkSdkError> {
31        match self {
32            SparkRpcClient::DefaultConnection(client) => {
33                Ok(SparkAuthnServiceClient::new(client.channel.clone()))
34            }
35        }
36    }
37}
38
39pub(crate) mod connections;
40pub(crate) mod traits;