use std::time::Duration;
pub const API_TIMEOUT: Duration = Duration::from_secs(15);
pub const DOWNLOAD_TIMEOUT: Duration = Duration::from_secs(120);
const SDK: &str = concat!("kiteconnect-rs/", env!("CARGO_PKG_VERSION"));
pub(crate) fn user_agent(app_name: Option<&str>) -> String {
match app_name {
Some(app_name) => format!("{app_name} {SDK}"),
None => SDK.to_string(),
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn user_agent_appends_the_sdk_version_to_the_app_name() {
let sdk = format!("kiteconnect-rs/{}", env!("CARGO_PKG_VERSION"));
assert_eq!(user_agent(None), sdk);
assert_eq!(
user_agent(Some("kite-cli/1.2.3")),
format!("kite-cli/1.2.3 {sdk}")
);
}
}