| Crates.io | klave-connector |
| lib.rs | klave-connector |
| version | 0.1.2 |
| created_at | 2025-04-29 17:59:36.885952+00 |
| updated_at | 2025-05-08 14:30:23.102048+00 |
| description | Module allowing easy connection to deployed Klave apps |
| homepage | https://klave.com/ |
| repository | https://github.com/secretarium/devsuite-rust.git |
| max_upload_size | |
| id | 1653878 |
| size | 124,327 |
This crate provides the necessary tools for connecting/interacting with Klave applications. It enables seamless communication with Klave apps and supports various features for secure and efficient integration.
It covers:
You can start from scratch with cargo add klave-connector or
Fork the Rust Connector repository.
Develop your app in Rust using the Klave Connector. Ensure the Rust packages you are using are compatible with tokio and asynchronous programming.
Build your project with:
cargo build --release
Deploy your app on Klave or integrate it into your existing Rust application.
use klave_connector::SCP;
use klave_connector::Key;
#[tokio::main]
async fn main() {
let mut client = SCP::new("<wss://your-endpoint>", None, None);
match client.connect().await {
Ok(_) => println!("Connected to Klave successfully."),
Err(e) => {
eprintln!("Failed to connect to Klave: {}", e);
return;
}
};
// Send a transaction
let mut tx = client.new_tx("<your-app>", "<your-route>", None, None).await;
tx.on_error(|request_id, error_message| {
eprintln!("Transaction error occurred. RequestId: {:?}, Error: {:?}", request_id, error_message);
});
tx.on_result(|request_id, result| {
eprintln!("Result received. RequestId: {:?}, Result: {:?}", request_id, result);
});
let _ = tx.send().await;
match client.close().await {
Ok(_) => println!("Connection closed successfully."),
Err(e) => eprintln!("Failed to close connection: {}", e),
};
}
Contributions to this crate are welcome! If you encounter any bugs or have suggestions for improvements, please open an issue on the GitHub repository.
This crate is licensed under the terms detailed in LICENSE.md.