### Move to Examples Directory Source: https://github.com/backpack-exchange/bpx-api-client/blob/master/README.md Command to change the current directory to the examples folder within the Rust client. This is typically done after building. ```bash cd examples ``` -------------------------------- ### Install Just Build Tool Source: https://github.com/backpack-exchange/bpx-api-client/blob/master/README.md Command to install the 'just' build tool using Cargo, the Rust package manager. This tool is used for simplifying build tasks. ```bash cargo install just ``` -------------------------------- ### REST API Example - Get Open Orders Source: https://github.com/backpack-exchange/bpx-api-client/blob/master/rust/client/README.md A Rust example demonstrating how to initialize the BpxClient and fetch open orders for a specific symbol using the REST API. It handles environment variables for base URL and secret key, and prints the orders or errors. ```rust use bpx_api_client::{BpxClient, BACKPACK_API_BASE_URL}; use std::env; #[tokio::main] async fn main() { let base_url = env::var("BASE_URL").unwrap_or_else(|_| BACKPACK_API_BASE_URL.to_string()); let secret = env::var("SECRET").expect("Missing SECRET environment variable"); let client = BpxClient::init(base_url, secret, None) .expect("Failed to initialize Backpack API client"); match client.get_open_orders(Some("SOL_USDC")).await { Ok(orders) => println!("Open Orders: {:?}", orders), Err(err) => tracing::error!("Error: {:?}", err), } } ``` -------------------------------- ### WebSocket API Example - Subscribe to RFQs Source: https://github.com/backpack-exchange/bpx-api-client/blob/master/rust/client/README.md A Rust example showing how to initialize the BpxClient with WebSocket support and subscribe to Request For Quote (RFQ) streams. It uses channels to receive and print RFQ messages. ```rust use anyhow::Result; use bpx_api_client::{BpxClient, BACKPACK_API_BASE_URL, BACKPACK_WS_URL}; use bpx_api_types::rfq::RequestForQuote; use std::env; use tokio::sync::mpsc; #[tokio::main] async fn main() -> Result<()> { let base_url = env::var("BASE_URL").unwrap_or_else(|_| BACKPACK_API_BASE_URL.to_string()); let ws_url = env::var("WS_URL").unwrap_or_else(|_| BACKPACK_WS_URL.to_string()); let secret = env::var("SECRET").expect("Missing SECRET environment variable"); let client = BpxClient::init_with_ws(base_url, ws_url, &secret, None)?; let (tx, mut rx) = mpsc::channel::(100); tokio::spawn(async move { while let Some(rfq) = rx.recv().await { println!("Received RFQ: {:?}", rfq); } }); client.subscribe_to_rfqs(tx).await; Ok(()) } ``` -------------------------------- ### Navigate to Rust Folder Source: https://github.com/backpack-exchange/bpx-api-client/blob/master/README.md Command to navigate to the Rust directory within the project. Assumes the user is in the project root. ```bash cd rust ``` -------------------------------- ### Build All Rust Packages Source: https://github.com/backpack-exchange/bpx-api-client/blob/master/README.md Command to build all packages within the Rust client using the 'just' build tool. This compiles the entire Rust project. ```bash just build ``` -------------------------------- ### Run Development Tasks with Just Source: https://github.com/backpack-exchange/bpx-api-client/blob/master/rust/client/README.md Shows how to use the 'just' command-line tool to manage build and development tasks for the project. Running 'just' without arguments lists available commands. ```shell just ``` -------------------------------- ### Enable WebSocket Support in Cargo.toml Source: https://github.com/backpack-exchange/bpx-api-client/blob/master/rust/client/README.md Demonstrates how to enable the 'ws' feature for the bpx_api_client crate in Cargo.toml to include WebSocket functionality. ```toml [dependencies] bpx_api_client = { version = "x.y.z", features = ["ws"] } ``` -------------------------------- ### Add bpx_api_client to Cargo.toml Source: https://github.com/backpack-exchange/bpx-api-client/blob/master/rust/client/README.md Specifies how to add the bpx_api_client crate as a dependency in a Rust project's Cargo.toml file. ```toml [dependencies] bpx_api_client = "x.y.z" # Replace with the latest version ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.