pub(crate) struct Rfc3339Formatter {
pub(crate) second: Option<i64>,
pub(crate) prefix: String,
}Expand description
Formats timestamps exactly like chrono’s to_rfc3339, faster.
Archived rows arrive in time order, so the date and time up to the second
changes only once per 100-2,000 rows. That part is built once per second
with chrono; only the fractional part is written per row, digit by digit,
following chrono’s to_rfc3339 rule: no fraction for whole seconds,
otherwise 3, 6 or 9 digits for millisecond, microsecond or nanosecond
precision.
Correctness does not depend on order: out-of-order timestamps only make the prefix rebuild more often.
Fields§
§second: Option<i64>Unix second the cached prefix belongs to, or None before the first call.
prefix: StringYYYY-MM-DDTHH:MM:SS text for the cached second.
Implementations§
Source§impl Rfc3339Formatter
impl Rfc3339Formatter
Sourcepub(crate) fn write(&mut self, out: &mut Vec<u8>, timestamp_unix_ns: i64)
pub(crate) fn write(&mut self, out: &mut Vec<u8>, timestamp_unix_ns: i64)
Appends one timestamp to out, reusing the date and time prefix if the
second is unchanged since the previous call.
§Arguments
out- Buffer the text is appended to.timestamp_unix_ns- Nanoseconds since the Unix epoch; anyi64, including negative values.
§Examples
1_790_000_000_008_000_000 -> "2026-09-21T14:13:20.008+00:00"
1_790_000_000_008_123_000 -> "2026-09-21T14:13:20.008123+00:00"
1_790_000_000_000_000_000 -> "2026-09-21T14:13:20+00:00"