CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-com-squareup-wire--wire-runtime

Runtime support library for Wire-generated Protocol Buffer classes in Kotlin multiplatform applications

Pending
Overview
Eval results
Files

time-types.mddocs/

Time Types

Cross-platform time and duration types that map to Google Well-Known Types (google.protobuf.Duration and google.protobuf.Timestamp). These provide consistent time handling across all Kotlin multiplatform targets.

Capabilities

Duration

Represents a time duration with nanosecond precision, mapping to google.protobuf.Duration.

/**
 * A measurement of time. Durations may be positive, zero, or negative.
 * Maps to google.protobuf.Duration
 */
expect class Duration {
    /** Get seconds component */
    fun getSeconds(): Long
    
    /** Get nanoseconds component (0-999,999,999) */
    fun getNano(): Int
}

/** Create duration from seconds and nanoseconds */
expect fun durationOfSeconds(seconds: Long, nano: Long): Duration

Instant

Represents a timestamp with nanosecond precision, mapping to google.protobuf.Timestamp.

/**
 * Represents a timestamp (google.protobuf.Timestamp)
 */
expect class Instant {
    /** Seconds since Unix epoch (1970-01-01T00:00:00Z) */
    fun getEpochSecond(): Long
    
    /** Nanoseconds component (0-999,999,999) */
    fun getNano(): Int
}

/** Create instant from epoch seconds and nanoseconds */
expect fun ofEpochSecond(epochSecond: Long, nano: Long): Instant

Usage Examples:

import com.squareup.wire.*

// Create duration (5.5 seconds)
val duration = durationOfSeconds(5, 500_000_000)
println("Seconds: ${duration.getSeconds()}") // 5
println("Nanos: ${duration.getNano()}")     // 500000000

// Create instant (Unix timestamp)
val instant = ofEpochSecond(1640995200, 123_456_789) // 2022-01-01T00:00:00.123456789Z
println("Epoch seconds: ${instant.getEpochSecond()}") // 1640995200
println("Nanos: ${instant.getNano()}")               // 123456789

// Use with ProtoAdapter
val encodedDuration = ProtoAdapter.DURATION.encode(duration)
val decodedDuration = ProtoAdapter.DURATION.decode(encodedDuration)

val encodedInstant = ProtoAdapter.INSTANT.encode(instant)
val decodedInstant = ProtoAdapter.INSTANT.decode(encodedInstant)

Install with Tessl CLI

npx tessl i tessl/maven-com-squareup-wire--wire-runtime

docs

any-message.md

enum-support.md

field-annotations.md

index.md

message-framework.md

proto-adapters.md

protobuf-io.md

time-types.md

tile.json