use exc_core::Str;
use serde::Deserialize;
use crate::error::OkxError;
#[derive(Debug, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct Params {
#[serde(alias = "family")]
pub inst_family: Option<Str>,
pub uly: Option<Str>,
}
pub fn parse_inst_tag(tag: &str) -> Result<(Str, Params), OkxError> {
let (tag, params) = tag
.split_once('?')
.map(|(ty, params)| serde_qs::from_str::<Params>(params).map(|p| (ty, p)))
.transpose()
.map_err(|err| OkxError::UnexpectedDataType(err.into()))?
.unwrap_or_else(|| (tag, Params::default()));
Ok((Str::new(tag), params))
}