Skip to content

Commit

Permalink
Regenerated the module bindings for the sdk tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cloutiertyler committed Dec 6, 2024
1 parent 96a3871 commit 55e12c9
Show file tree
Hide file tree
Showing 11 changed files with 611 additions and 10 deletions.
16 changes: 8 additions & 8 deletions crates/bindings-csharp/BSATN.Runtime/Builtins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,30 +304,30 @@ public AlgebraicType GetAlgebraicType(ITypeRegistrar registrar) =>

// [SpacetimeDB.Type] - we have custom representation of time in microseconds, so implementing BSATN manually
public abstract partial record ScheduleAt
: SpacetimeDB.TaggedEnum<(DateTimeOffset Time, TimeSpan Interval)>
: SpacetimeDB.TaggedEnum<(TimeSpan Interval, DateTimeOffset Time)>
{
// Manual expansion of what would be otherwise generated by the [SpacetimeDB.Type] codegen.
public sealed record Time(DateTimeOffset Time_) : ScheduleAt;

public sealed record Interval(TimeSpan Interval_) : ScheduleAt;

public static implicit operator ScheduleAt(DateTimeOffset time) => new Time(time);
public sealed record Time(DateTimeOffset Time_) : ScheduleAt;

public static implicit operator ScheduleAt(TimeSpan interval) => new Interval(interval);

public static implicit operator ScheduleAt(DateTimeOffset time) => new Time(time);

public readonly partial struct BSATN : IReadWrite<ScheduleAt>
{
[SpacetimeDB.Type]
private partial record ScheduleAtRepr
: SpacetimeDB.TaggedEnum<(DateTimeOffsetRepr Time, TimeSpanRepr Interval)>;
: SpacetimeDB.TaggedEnum<(TimeSpanRepr Interval, DateTimeOffsetRepr Time)>;

private static readonly ScheduleAtRepr.BSATN ReprBSATN = new();

public ScheduleAt Read(BinaryReader reader) =>
ReprBSATN.Read(reader) switch
{
ScheduleAtRepr.Time(var timeRepr) => new Time(timeRepr.ToStd()),
ScheduleAtRepr.Interval(var intervalRepr) => new Interval(intervalRepr.ToStd()),
ScheduleAtRepr.Time(var timeRepr) => new Time(timeRepr.ToStd()),
_ => throw new SwitchExpressionException(),
};

Expand All @@ -337,8 +337,8 @@ public void Write(BinaryWriter writer, ScheduleAt value)
writer,
value switch
{
Time(var time) => new ScheduleAtRepr.Time(new(time)),
Interval(var interval) => new ScheduleAtRepr.Interval(new(interval)),
Time(var time) => new ScheduleAtRepr.Time(new(time)),
_ => throw new SwitchExpressionException(),
}
);
Expand All @@ -349,8 +349,8 @@ public AlgebraicType GetAlgebraicType(ITypeRegistrar registrar) =>
// to avoid leaking the internal *Repr wrappers in generated SATS.
new AlgebraicType.Sum(
[
new("Time", new AlgebraicType.U64(default)),
new("Interval", new AlgebraicType.U64(default)),
new("Time", new AlgebraicType.U64(default)),
]
);
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 55e12c9

Please sign in to comment.