Expand description
Interval types for historical market data with dual string/integer serialization support.
This module provides the Interval enum for specifying time intervals in historical data requests.
The v1.0.3 enhancement adds dual serde support, accepting both string and integer formats during
deserialization while always serializing as strings for API consistency.
§Dual Serde Support (v1.0.3)
The Interval enum now supports flexible input formats:
- Strings: “minute”, “day”, “5minute”, etc. (human-readable)
- Integers: 1, 0, 3, etc. (compact, legacy support)
It always serializes as strings for API compatibility and human readability.
§Examples
§Basic Usage
use kiteconnect_async_wasm::models::common::Interval;
let interval = Interval::Day;
assert_eq!(interval.to_string(), "day");§Deserialization Flexibility
use kiteconnect_async_wasm::models::common::Interval;
// From strings (human-readable)
let from_string: Interval = serde_json::from_str("\"day\"").unwrap();
let from_minute: Interval = serde_json::from_str("\"5minute\"").unwrap();
// From integers (compact)
let from_int: Interval = serde_json::from_str("0").unwrap(); // Day
let from_five: Interval = serde_json::from_str("3").unwrap(); // FiveMinute
assert_eq!(from_string, from_int);
assert_eq!(from_minute, from_five);§Serialization Consistency
use kiteconnect_async_wasm::models::common::Interval;
// Always serializes as strings
assert_eq!(serde_json::to_string(&Interval::Day).unwrap(), "\"day\"");
assert_eq!(serde_json::to_string(&Interval::FiveMinute).unwrap(), "\"5minute\"");Enums§
- Interval
- Interval types for historical data with dual serialization support