### SBXCloud Rust SDK This is the Rust SDK for SBXCloud. It is a work in progress and is not yet ready for production use. ## Required environment variables: SBX_HOST: The host of the SBXCloud instance, this will default to `https://sbxcloud.com` SBX_TOKEN: The token to use for authentication (Required) SBX_APP_KEY: The app key to use for authentication (Optional) SBX_DOMAIN: The domain context from SBXCloud where the data is stored (Required), this must be a positive number ## Implemented features: - [ ] Authentication - [x] QueryBuilder - [x] load_all (QueryBuilder) that will load all the results from the query - [x] Fetch related records via fetch ## Code examples The library requires you to use an async runtime, so you will need to use an async runtime to use this library. The examples below use tokio. ```rust use sbx_cloud::models::{QueryBuilder, SBXClient}; use sbx_cloud::services::load_all; #[derive(Serialize, Deserialize, Debug, Clone)] struct Purchase { #[serde(rename(serialize = "_KET", deserialize = "_KEY"))] key: String, consecutive: u32, } #[tokio::main] async fn main() -> Result<(), Box> { // use the default SBXClient let sbx = SBXClient::default(); // Search for for all the items on the purchase table let q = QueryBuilder::new("purchase", sbx.domain) // fetch the associated customer .fetch(vec![String::from("customer")]) // where the packing date of the order is equal to a given date .and_equals("packing_date", date) // and the checkout is not null .and_is_not_null("checkout") // compile the query .build(); // perform the query and load all the results match load_all::(&sbx, &q).await { Ok((purchases, fetch)) => { println!("Found {} purchases", purchases.len()); // print out the purchases for purchase in purchases.iter() { println!("Purchase: {}", purchase.key); } println!("Found {} fetches", fetch.len()); Ok(()) } Err(e) => { println!("Error: {}", e); Err(e) } } } ```