-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[centril/websocket-use-ids]: Merge commit 'origin/master~1' into cent…
…ril/websocket-use-ids
- Loading branch information
Showing
20 changed files
with
679 additions
and
587 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
namespace SpacetimeDB.Internal; | ||
|
||
using System.Runtime.InteropServices; | ||
|
||
// We store time information in microseconds in internal usages. | ||
// | ||
// These utils allow to encode it as such in FFI and BSATN contexts | ||
// and convert to standard C# types. | ||
|
||
[StructLayout(LayoutKind.Sequential)] // we should be able to use it in FFI | ||
[SpacetimeDB.Type] // we should be able to encode it to BSATN too | ||
public partial struct DateTimeOffsetRepr(DateTimeOffset time) | ||
{ | ||
public ulong MicrosecondsSinceEpoch = (ulong)time.Ticks / 10; | ||
|
||
public readonly DateTimeOffset ToStd() => | ||
DateTimeOffset.UnixEpoch.AddTicks(10 * (long)MicrosecondsSinceEpoch); | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential)] // we should be able to use it in FFI | ||
[SpacetimeDB.Type] // we should be able to encode it to BSATN too | ||
public partial struct TimeSpanRepr(TimeSpan duration) | ||
{ | ||
public ulong Microseconds = (ulong)duration.Ticks / 10; | ||
|
||
public readonly TimeSpan ToStd() => TimeSpan.FromTicks(10 * (long)Microseconds); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.