liminal_sdk/remote/config.rs
1use crate::embedded::EmbeddedConfig;
2use crate::{ChannelHandle, ConversationHandle, SdkError};
3
4use super::{RemoteConfig, SdkChannelHandle, SdkConversationHandle};
5
6/// Deployment-mode configuration used by the SDK builders.
7#[derive(Clone, Debug)]
8pub enum SdkConfig {
9 /// Direct in-process deployment with no server address or sockets.
10 Embedded(EmbeddedConfig),
11 /// Remote deployment using the SDK-internal wire protocol transport.
12 Remote(RemoteConfig),
13}
14
15impl SdkConfig {
16 /// Creates embedded deployment configuration.
17 #[must_use]
18 pub const fn embedded(config: EmbeddedConfig) -> Self {
19 Self::Embedded(config)
20 }
21
22 /// Creates remote deployment configuration.
23 #[must_use]
24 pub const fn remote(config: RemoteConfig) -> Self {
25 Self::Remote(config)
26 }
27
28 /// Builds a channel handle selected only by this configuration.
29 ///
30 /// # Errors
31 ///
32 /// Returns [`SdkError`] if the selected mode cannot be initialized.
33 pub fn channel_handle(&self) -> Result<SdkChannelHandle, SdkError> {
34 SdkChannelHandle::new(self)
35 }
36
37 /// Builds a conversation handle selected only by this configuration.
38 ///
39 /// # Errors
40 ///
41 /// Returns [`SdkError`] if the selected mode cannot be initialized.
42 pub fn conversation_handle(&self) -> Result<SdkConversationHandle, SdkError> {
43 SdkConversationHandle::new(self)
44 }
45}
46
47/// Builds a channel handle selected by [`SdkConfig`].
48///
49/// # Errors
50///
51/// Returns [`SdkError`] if the selected mode cannot be initialized.
52pub fn build_channel_handle(config: &SdkConfig) -> Result<impl ChannelHandle, SdkError> {
53 config.channel_handle()
54}
55
56/// Builds a conversation handle selected by [`SdkConfig`].
57///
58/// # Errors
59///
60/// Returns [`SdkError`] if the selected mode cannot be initialized.
61pub fn build_conversation_handle(config: &SdkConfig) -> Result<impl ConversationHandle, SdkError> {
62 config.conversation_handle()
63}