A convenience function to build timestamp values from underlying longs.
(value: i64, unit: TsUnit)
| 454 | |
| 455 | /// A convenience function to build timestamp values from underlying longs. |
| 456 | pub fn build_ts_value(value: i64, unit: TsUnit) -> Result<Value, AvroError> { |
| 457 | let result = match unit { |
| 458 | TsUnit::Millis => DateTime::from_timestamp_millis(value), |
| 459 | TsUnit::Micros => DateTime::from_timestamp_micros(value), |
| 460 | }; |
| 461 | let ndt = result.ok_or(AvroError::Decode(DecodeError::BadTimestamp { unit, value }))?; |
| 462 | Ok(Value::Timestamp(ndt.naive_utc())) |
| 463 | } |
| 464 | |
| 465 | /// A convenience trait for types that are both readable and skippable. |
| 466 | /// |
no test coverage detected