MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / build_ts_value

Function build_ts_value

src/avro/src/decode.rs:456–463  ·  view source on GitHub ↗

A convenience function to build timestamp values from underlying longs.

(value: i64, unit: TsUnit)

Source from the content-addressed store, hash-verified

454
455/// A convenience function to build timestamp values from underlying longs.
456pub 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///

Callers 2

try_make_long_valueMethod · 0.85
deserializeMethod · 0.85

Calls 1

TimestampClass · 0.50

Tested by

no test coverage detected