MCPcopy Create free account
hub / github.com/Keats/jsonwebtoken / serialize

Function serialize

examples/custom_time.rs:45–51  ·  view source on GitHub ↗

Serializes an OffsetDateTime to a Unix timestamp (milliseconds since 1970/1/1T00:00:00T)

(date: &OffsetDateTime, serializer: S)

Source from the content-addressed store, hash-verified

43
44 /// Serializes an OffsetDateTime to a Unix timestamp (milliseconds since 1970/1/1T00:00:00T)
45 pub fn serialize<S>(date: &OffsetDateTime, serializer: S) -> Result<S::Ok, S::Error>
46 where
47 S: Serializer,
48 {
49 let timestamp = date.unix_timestamp();
50 serializer.serialize_i64(timestamp)
51 }
52
53 /// Attempts to deserialize an i64 and use as a Unix timestamp
54 pub fn deserialize<'de, D>(deserializer: D) -> Result<OffsetDateTime, D::Error>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected