Skip to content

Conversation

@boivie
Copy link
Collaborator

@boivie boivie commented Dec 19, 2025

Instant is a complicated type as it's opaque, and only useful with Duration. It cannot be created from a value, and it cannot be serialized and deserialized, and works poorly when interfacing C++. It typically represents the current time.

This change introduces a type called SocketTime that represent a point in time relative to the socket's creation time. It's a strong type, wrapping a Duration, and with the definition that it's zero when the socket is created, the current time no longer has to be passed to the socket constructor.

This simplifies interfacing with C++, and overall simplifies the API.

CXX FFI is updated in this change as well, to see how it's used. Note that the CXX FFI uses a u64 (in nanoseconds) as its view of duration (everywhere). That limits the socket lifetime to 585 years, which is okey. The Rust API has the full Duration.

@boivie boivie force-pushed the feature-sockettime branch from 044621a to 7ef6f5b Compare December 19, 2025 19:57
@boivie boivie changed the title jUse new SocketTime replacing Instant Use new SocketTime replacing Instant Dec 19, 2025
@boivie boivie requested a review from lndmrk December 19, 2025 19:58
@boivie boivie force-pushed the feature-sockettime branch 4 times, most recently from f301aff to 3bd1ce6 Compare December 22, 2025 21:40
Instant is a complicated type as it's opaque, and only useful
with Duration. It cannot be created from a value, and it cannot
be serialized and deserialized, and works poorly when interfacing
C++. It typically represents the current time.

This change introduces a type called SocketTime that represent a
point in time relative to the socket's creation time. It's a strong
type, wrapping an u64 representing nanoseconds since the socket was 
created.

This simplifies interfacing with C++, and overall simplifies the API.
@boivie boivie force-pushed the feature-sockettime branch 2 times, most recently from 88c50fa to ce167e8 Compare January 8, 2026 12:39
@boivie boivie requested a review from lndmrk January 8, 2026 12:41
@boivie boivie force-pushed the feature-sockettime branch from ce167e8 to 07a187c Compare January 8, 2026 13:11
@boivie boivie merged commit 99d43d8 into webrtc:main Jan 8, 2026
10 checks passed
@boivie boivie deleted the feature-sockettime branch January 8, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants