MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / parse_credential_expiry_value

Function parse_credential_expiry_value

crates/openshell-cli/src/run.rs:4068–4099  ·  view source on GitHub ↗
(value: &str, key: Option<&str>)

Source from the content-addressed store, hash-verified

4066}
4067
4068fn parse_credential_expiry_value(value: &str, key: Option<&str>) -> Result<i64> {
4069 let value = value.trim();
4070 if value.is_empty() {
4071 return Err(credential_expiry_value_error(key, "cannot be empty"));
4072 }
4073
4074 if let Ok(value_ms) = value.parse::<i64>() {
4075 if value_ms < 0 {
4076 return Err(credential_expiry_value_error(
4077 key,
4078 "must be greater than or equal to 0",
4079 ));
4080 }
4081 return Ok(value_ms);
4082 }
4083
4084 let parsed = DateTime::parse_from_rfc3339(value).map_err(|_| {
4085 credential_expiry_value_error(
4086 key,
4087 "must be a Unix epoch millisecond timestamp or RFC3339 timestamp",
4088 )
4089 })?;
4090 let value_ms = parsed.timestamp_millis();
4091 if value_ms < 0 {
4092 return Err(credential_expiry_value_error(
4093 key,
4094 "must be greater than or equal to 0",
4095 ));
4096 }
4097
4098 Ok(value_ms)
4099}
4100
4101fn parse_credential_expiry_pairs(items: &[String]) -> Result<HashMap<String, i64>> {
4102 let mut map = HashMap::new();

Calls 2

is_emptyMethod · 0.45

Tested by

no test coverage detected