pub struct Client {
pub news: NewsService,
pub common: CommonService,
pub market: MarketService,
pub delivery: DeliveryService,
pub member: MemberService,
pub trade: TradeService,
pub settle: SettleService,
/* private fields */
}Expand description
DCE API client.
This is the main entry point for using the DCE API. It provides access to all API services through dedicated service instances.
§Example
use dceapi::{Client, Config};
#[tokio::main]
async fn main() -> dceapi::Result<()> {
let config = Config::new()
.with_api_key("your-api-key")
.with_secret("your-secret");
let client = Client::new(config)?;
// Get current trade date
let trade_date = client.common.get_curr_trade_date(None).await?;
println!("Trade date: {}", trade_date.date);
Ok(())
}Fields§
§news: NewsServiceNews service for articles and announcements.
common: CommonServiceCommon service for trade dates and varieties.
market: MarketServiceMarket service for quotes and market data.
delivery: DeliveryServiceDelivery service for delivery data.
member: MemberServiceMember service for member rankings.
trade: TradeServiceTrade service for trading parameters.
settle: SettleServiceSettlement service for settlement parameters.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(config: Config) -> Result<Self>
pub fn new(config: Config) -> Result<Self>
Create a new DCE API client.
§Arguments
config- Client configuration with API credentials
§Errors
Returns an error if the configuration is invalid (missing API key or secret).
§Example
use dceapi::{Client, Config};
let config = Config::new()
.with_api_key("your-api-key")
.with_secret("your-secret");
let client = Client::new(config).expect("Failed to create client");Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Create a new client from environment variables.
Reads DCE_API_KEY and DCE_SECRET from the environment.
§Errors
Returns an error if the environment variables are not set.
Sourcepub fn token_manager(&self) -> &TokenManager
pub fn token_manager(&self) -> &TokenManager
Get the token manager.
This can be used for advanced token management, such as forcing a refresh.