### Run Example via Cargo Source: https://github.com/yezz123/rain-rust-sdk/blob/main/README.md Execute a specific example using the cargo CLI with the async feature enabled. ```bash cargo run --example signup_consumer --features async ``` -------------------------------- ### Install Taplo CLI Source: https://github.com/yezz123/rain-rust-sdk/blob/main/taplo/README.md Commands to install the Taplo CLI globally using different package managers. ```bash cargo install taplo-cli --locked ``` ```bash yarn global add @taplo/cli ``` ```bash npm install -g @taplo/cli ``` -------------------------------- ### Initialize and use RainClient synchronously Source: https://github.com/yezz123/rain-rust-sdk/blob/main/README.md Demonstrates setting up the RainClient and performing a blocking user application initiation. ```rust use rain_sdk::{RainClient, Config, Environment, AuthConfig}; use rain_sdk::models::applications::InitiateUserApplicationRequest; fn main() -> Result<(), Box> { let config = Config::new(Environment::Dev); let auth = AuthConfig::with_api_key("your-api-key".to_string()); let client = RainClient::new(config, auth)?; let request = InitiateUserApplicationRequest { first_name: "John".to_string(), last_name: "Doe".to_string(), email: "john@example.com".to_string(), wallet_address: None, }; let application = client.initiate_user_application_blocking(&request)?; println!("Application ID: {}", application.id); Ok(()) } ``` -------------------------------- ### Initialize and use RainClient asynchronously Source: https://github.com/yezz123/rain-rust-sdk/blob/main/README.md Demonstrates setting up the RainClient with an API key and performing an asynchronous user application initiation. ```rust use rain_sdk::{RainClient, Config, Environment, AuthConfig}; use rain_sdk::models::applications::InitiateUserApplicationRequest; use uuid::Uuid; #[tokio::main] async fn main() -> Result<(), Box> { // Create configuration for dev environment let config = Config::new(Environment::Dev); // Create authentication config with API key let auth = AuthConfig::with_api_key("your-api-key".to_string()); // Create the client let client = RainClient::new(config, auth)?; // Initiate a user application let request = InitiateUserApplicationRequest { first_name: "John".to_string(), last_name: "Doe".to_string(), email: "john@example.com".to_string(), wallet_address: None, }; let application = client.initiate_user_application(&request).await?; println!("Application ID: {}", application.id); Ok(()) } ``` -------------------------------- ### Configure SDK Environment Source: https://github.com/yezz123/rain-rust-sdk/blob/main/README.md Select between development, production, or custom API endpoints. ```rust // Dev (default) let config = Config::new(Environment::Dev); // Production let config = Config::new(Environment::Production); // Custom URL let config = Config::new(Environment::Custom( url::Url::parse("https://api.custom.com/v1")? )); ``` -------------------------------- ### Authenticate with API Key Source: https://github.com/yezz123/rain-rust-sdk/blob/main/README.md Initialize the authentication configuration using an API key. ```rust let auth = AuthConfig::with_api_key("your-api-key".to_string()); ``` -------------------------------- ### Apply Custom Configuration Source: https://github.com/yezz123/rain-rust-sdk/blob/main/README.md Customize SDK behavior by setting timeouts, user agents, and logging preferences. ```rust let config = Config::new(Environment::Dev) .with_timeout(60) // 60 second timeout .with_user_agent("my-app/1.0".to_string()) .with_logging(true); ``` -------------------------------- ### Configure Cargo dependencies Source: https://github.com/yezz123/rain-rust-sdk/blob/main/README.md Add the required features to your Cargo.toml file based on whether you need async or sync operations. ```toml [dependencies] rain-sdk = { version = "0.1.0", features = ["async"] } ``` ```toml [dependencies] rain-sdk = { version = "0.1.0", features = ["sync"] } ``` -------------------------------- ### Format and Check TOML Files Source: https://github.com/yezz123/rain-rust-sdk/blob/main/taplo/README.md Commands to check formatting or apply automatic formatting to TOML files using a configuration file. ```bash npx @taplo/cli fmt --config taplo.toml --check ``` ```bash npx @taplo/cli fmt --config taplo.toml ``` -------------------------------- ### Handle API Errors Source: https://github.com/yezz123/rain-rust-sdk/blob/main/README.md Pattern match against RainError variants to handle API, HTTP, and authentication errors appropriately. ```rust use rain_sdk::error::RainError; match client.get_user_application(&user_id).await { Ok(application) => println!("Success: {:?}", application), Err(RainError::ApiError { status, response }) => { println!("API error (status {}): {}", status, response); // Common status codes: // - 400: Invalid request // - 401: Invalid authorization // - 403: Forbidden // - 404: Not found // - 409: Conflict // - 423: Locked // - 500: Internal server error }, Err(RainError::HttpError(err)) => println!("HTTP error: {}", err), Err(RainError::AuthError(msg)) => println!("Auth error: {}", msg), Err(e) => println!("Other error: {}", e), } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.