1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//! # Example Executor
//! ```rust
//! use rship_sdk::{ActionArgs, EmitterArgs, InstanceArgs, SdkClient, TargetArgs};
//! use schemars::JsonSchema;
//! use serde::{Deserialize, Serialize};
//!
//! #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
//! pub struct MyActionData {
//! pub data: String,
//! }
//!
//! #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
//! pub struct MyEmitterType {
//! pub data: String,
//! }
//!
//! pub async fn start_client() {
//! // Initialize logger
//! env_logger::init();
//!
//! // Load the environment variables
//! let address = std::env::var("RSHIP_ADDRESS").unwrap_or_else(|_| "dev.rship.io".to_string());
//! let port = std::env::var("RSHIP_PORT").unwrap_or_else(|_| "5155".to_string());
//! let url = format!("ws://{}:{}/myko", address, port);
//! log::info!("Connecting to: {}", url);
//!
//! // Create a new sdk client
//! let sdk = SdkClient::init();
//! sdk.set_address(Some(url));
//!
//! // Wait for the client to connect
//! sdk.await_connection().await;
//!
//! // Create an instance
//! let instance = sdk
//! .add_instance(InstanceArgs {
//! name: "Rust SDK Example".into(),
//! short_id: "rust-sdk-example".into(),
//! code: "rust-sdk-example".into(),
//! service_id: "rust-sdk-service".into(),
//! cluster_id: None,
//! color: "#FF6B35".into(),
//! machine_id: "rust-sdk-machine".into(),
//! message: Some("Hello from Rust SDK!".into()),
//! status: rship_sdk::InstanceStatus::Available,
//! })
//! .await;
//!
//! // Create a target
//! let mut target = instance
//! .add_target(TargetArgs {
//! name: "SDK Example Target".into(),
//! short_id: "sdk-example-target".into(),
//! category: "examples".into(),
//! parent_targets: None,
//! })
//! .await;
//!
//! // Add an action to the target
//! target
//! .add_action(
//! ActionArgs::<MyActionData>::new("Print Log".into(), "print-log".into()),
//! |action, data| {
//! println!("{}", data.data);
//! },
//! )
//! .await;
//!
//! // Add an emitter to the target
//! let emitter = target
//! .add_emitter(EmitterArgs::<MyEmitterType>::new(
//! "Example Emitter".into(),
//! "example-emitter".into(),
//! ))
//! .await;
//!
//! // Pulse the emitter
//! let mut counter = 0;
//! loop {
//! emitter.pulse(MyEmitterType { data: format!("{}", counter) }).await.expect("Failed to pulse emitter");
//! counter += 1;
//! tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
//! }
//! }
//!
//! #[tokio::main]
//! async fn main() {
//! start_client().await;
//! }
//! ```
pub use ;
pub use SdkClient;
pub use ;
pub use ;
pub use ;
pub use ConcreteSchemaType;
pub use EventTrackTimeMode;
pub use InstanceStatus;
pub use ;
pub use JsonSchema;
pub use ;