diff --git a/stellar_rust_sdk/src/lib.rs b/stellar_rust_sdk/src/lib.rs index e6b4004..dd9dc1a 100644 --- a/stellar_rust_sdk/src/lib.rs +++ b/stellar_rust_sdk/src/lib.rs @@ -348,6 +348,42 @@ pub mod effects; /// pub mod fee_stats; +/// Provides `Request` and `Response` structs for retrieving liquidity pools. +/// +/// The `liquidity_pools` module in the Stellar Horizon SDK includes structures and methods that facilitate +/// querying liquidity pool data from the Horizon server. +/// +/// # Usage +/// +/// This module is used to construct requests for liquidity pool related data and to parse the responses +/// received from the Horizon server. It includes request and response structures for querying +/// liquidity pool data. +/// +/// # Example +/// +/// To use this module, you can create an instance of a request struct, such as `SingleLiquidityPoolRequest`, +/// and pass the request to the `HorizonClient`. The client will then execute the request and +/// return the corresponding response struct, like `LiquidityPool`. +/// +/// ```rust +/// # use stellar_rs::horizon_client::HorizonClient; +/// # use stellar_rs::liquidity_pools::prelude::*; +/// # use stellar_rs::models::Request; +/// +/// # async fn example() -> Result<(), Box> { +/// let horizon_client = HorizonClient::new("https://horizon-testnet.stellar.org".to_string())?; +/// +/// // Example: Fetching fee stats +/// let single_lp_request = SingleLiquidityPoolRequest::new() +/// .set_liquidity_pool_id("000000006520216af66d20d63a58534d6cbdf28ba9f2a9c1e03f8d9a756bb7d988b29bca".to_string()) +/// .unwrap(); +/// let lp_response = horizon_client.get_single_liquidity_pool(&single_lp_request).await?; +/// +/// // Process the response... +/// # Ok(()) +/// # } +/// ``` +/// pub mod liquidity_pools; /// Provides `Request` and `Response` structs for retrieving offers. diff --git a/stellar_rust_sdk/src/liquidity_pools/all_liquidity_pools_request.rs b/stellar_rust_sdk/src/liquidity_pools/all_liquidity_pools_request.rs index c6878bd..8d3955a 100644 --- a/stellar_rust_sdk/src/liquidity_pools/all_liquidity_pools_request.rs +++ b/stellar_rust_sdk/src/liquidity_pools/all_liquidity_pools_request.rs @@ -12,7 +12,7 @@ pub struct Reserve { /// to filter by when querying the Horizon server for liquidity pool records. #[derive(PartialEq, Debug)] pub enum ReserveType { - /// A native reserve type. It holds no Value + /// A native reserve type. It holds no value. Native, /// An alphanumeric 4 reserve type. It holds a Reserve struct with asset code and asset issuer. Alphanumeric4(Reserve), @@ -51,15 +51,12 @@ pub struct AllLiquidityPoolsRequest { /// A pointer to a specific location in a collection of responses, derived from the /// `paging_token` value of a record. Used for pagination control in the API response. cursor: Option, - /// Specifies the maximum number of records to be returned in a single response. /// The range for this parameter is from 1 to 200. The default value is set to 10. limit: Option, - /// Determines the [`Order`] of the records in the response. Valid options are [`Order::Asc`] (ascending) /// and [`Order::Desc`] (descending). If not specified, it defaults to ascending. order: Option, - /// A list of reserves to filter by. reserves: Option>, } diff --git a/stellar_rust_sdk/src/liquidity_pools/mod.rs b/stellar_rust_sdk/src/liquidity_pools/mod.rs index cdc083e..495ab3c 100644 --- a/stellar_rust_sdk/src/liquidity_pools/mod.rs +++ b/stellar_rust_sdk/src/liquidity_pools/mod.rs @@ -1,9 +1,68 @@ +/// Provides the `SingleLiquidityPoolRequest`. +/// +/// This module provides the `SingleLiquidityPoolRequest` struct, specifically designed for +/// constructing requests to query information about a single liquidity pool from the Horizon +/// server. It is tailored for use with the [`HorizonClient::get_single_liquidity_pool`](crate::horizon_client::HorizonClient::get_single_liquidity_pool) +/// method. +/// +pub mod single_liquidity_pool_request; + +/// Provides the `AllLiquidityPoolsRequest`. +/// +/// This module provides the `AllLiquidityPoolsRequest` struct, specifically designed for +/// constructing requests to query information about all liquidity pools from the Horizon +/// server. It is tailored for use with the [`HorizonClient::get_all_liquidity_pools`](crate::horizon_client::HorizonClient::get_all_liquidity_pools) +/// method. pub mod all_liquidity_pools_request; + +/// Provides the responses. +/// +/// This module defines structures representing the response from the Horizon API when querying +/// for liquidity pools. The structures are designed to deserialize the JSON response into Rust +/// objects, enabling straightforward access to various details of a single Stellar account. +/// +/// These structures are equipped with serialization capabilities to handle the JSON data from the +/// Horizon server and with getter methods for easy field access. +/// pub mod response; -pub mod single_liquidity_pool_request; +/// The base path for liquidity pool related endpoints in the Horizon API. +/// +/// # Usage +/// This variable is intended to be used internally by the request-building logic +/// to ensure consistent and accurate path construction for liquidity pool related API calls. +/// static LIQUIDITY_POOLS_PATH: &str = "liquidity_pools"; +/// The `prelude` module of the `liquidity_pools` module. +/// +/// This module serves as a convenience for users of the Horizon Rust SDK, allowing for easy and +/// ergonomic import of the most commonly used items across various modules. It re-exports +/// key structs and traits from the sibling modules, simplifying access to these components +/// when using the library. +/// +/// By importing the contents of `prelude`, users can conveniently access the primary +/// functionalities of the liquidity pool related modules without needing to import each item +/// individually. +/// +/// # Contents +/// +/// The `prelude` includes the following re-exports: +/// +/// * From `single_liquidity_pool_request`: All items (e.g. `SingleLiquidityPoolRequest`). +/// * From `all_liquidity_pools_request`: All items (e.g. `AllLiquidityPoolsRequest`, `Reserve`, etc.). +/// * From `response`: All items (e.g. `AllLiquidityPoolsResponse`, `Reserve`, etc.). +/// +/// # Example +/// ``` +/// # use crate::stellar_rs::models::*; +/// // Import the contents of the liquidity pools prelude +/// use stellar_rs::liquidity_pools::prelude::*; +/// +/// // Now you can directly use SingleLiquidityPoolRequest, LiquidityPool, etc. +/// let single_lp_request = SingleLiquidityPoolRequest::new(); +/// ``` +/// pub mod prelude { pub use super::response::*; pub use super::single_liquidity_pool_request::*; diff --git a/stellar_rust_sdk/src/liquidity_pools/response.rs b/stellar_rust_sdk/src/liquidity_pools/response.rs index c0421c1..60cd89c 100644 --- a/stellar_rust_sdk/src/liquidity_pools/response.rs +++ b/stellar_rust_sdk/src/liquidity_pools/response.rs @@ -18,6 +18,7 @@ pub struct AllLiquidityPoolsResponse { #[serde(rename = "_embedded")] pub embedded: Embedded, } + /// Represents a single liquidity pool record in the Horizon API response. /// /// This struct encapsulates detailed information about a single liquidity pool, including its ID, diff --git a/stellar_rust_sdk/src/liquidity_pools/single_liquidity_pool_request.rs b/stellar_rust_sdk/src/liquidity_pools/single_liquidity_pool_request.rs index 4351aae..c6b58f7 100644 --- a/stellar_rust_sdk/src/liquidity_pools/single_liquidity_pool_request.rs +++ b/stellar_rust_sdk/src/liquidity_pools/single_liquidity_pool_request.rs @@ -1,6 +1,10 @@ use crate::models::Request; + +/// Represents the liquidity pool ID. #[derive(Default, Clone)] pub struct LiquidityPoolId(String); + +/// Represents the absence of a liquidity pool ID. #[derive(Default, Clone)] pub struct NoLiquidityPoolId; @@ -25,7 +29,7 @@ pub struct NoLiquidityPoolId; /// # use stellar_rs::liquidity_pools::prelude::SingleLiquidityPoolRequest; /// # use stellar_rs::models::Request; /// let request = SingleLiquidityPoolRequest::new() -/// .set_liquidity_pool_id("1".to_string()) +/// .set_liquidity_pool_id("000000006520216af66d20d63a58534d6cbdf28ba9f2a9c1e03f8d9a756bb7d988b29bca".to_string()) /// .unwrap(); /// // Use with HorizonClient::get_single_liquidity_pool /// ```