diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 149fdd98aa0..ed34802f604 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -120,6 +120,7 @@ jobs: run: | sudo mkdir /stdb sudo chmod 777 /stdb + - name: Checkout C# SDK uses: actions/checkout@v4 with: @@ -127,42 +128,18 @@ jobs: ref: staging path: spacetimedb-csharp-sdk - - name: C# SDK tests + - name: Setup NuGet override for C# SDK + working-directory: spacetimedb-csharp-sdk run: | - ( cd crates/bindings-csharp/BSATN.Runtime && dotnet pack ) - cd spacetimedb-csharp-sdk - - # Write out the nuget config file to `nuget.config`. This causes the spacetimedb-csharp-sdk repository - # to be aware of the local versions of the `bindings-csharp` packages in SpacetimeDB, and use them if - # available. Otherwise, `spacetimedb-csharp-sdk` will use the NuGet versions of the packages. - # This means that (if version numbers match) we will test the local versions of the C# packages, even - # if they're not pushed to NuGet. - # See https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file for more info on the config file, - # and https://tldp.org/LDP/abs/html/here-docs.html for more info on this bash feature. - cat >nuget.config < - - - - - - - - - - - - - - - - - - EOF + dotnet pack ../crates/bindings-csharp/BSATN.Runtime + ./tools~/write-nuget-config.sh .. # clear package caches, so we get fresh ones even if version numbers haven't changed dotnet nuget locals all --clear - dotnet test + + - name: Run C# SDK tests + working-directory: spacetimedb-csharp-sdk + run: dotnet test lints: name: Lints diff --git a/Cargo.lock b/Cargo.lock index 689fa2e2f73..ede0accf80d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -459,15 +459,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitmaps" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2" -dependencies = [ - "typenum", -] - [[package]] name = "bitvec" version = "1.0.1" @@ -2500,20 +2491,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "im" -version = "15.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9" -dependencies = [ - "bitmaps", - "rand_core 0.6.4", - "rand_xoshiro", - "sized-chunks", - "typenum", - "version_check", -] - [[package]] name = "imara-diff" version = "0.1.7" @@ -3917,15 +3894,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "rand_xoshiro" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" -dependencies = [ - "rand_core 0.6.4", -] - [[package]] name = "rayon" version = "1.10.0" @@ -4747,16 +4715,6 @@ version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" -[[package]] -name = "sized-chunks" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e" -dependencies = [ - "bitmaps", - "typenum", -] - [[package]] name = "slab" version = "0.4.9" @@ -5336,7 +5294,6 @@ dependencies = [ "hex", "home", "http 1.1.0", - "im", "log", "rand 0.8.5", "spacetimedb-client-api-messages", diff --git a/Cargo.toml b/Cargo.toml index caac2d75108..69558f2ada5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -166,7 +166,6 @@ http = "1.0" humantime = "2.1.0" hyper = "1.0" hyper-util = { version = "0.1", features = ["tokio"] } -im = "15.1" imara-diff = "0.1.3" indexmap = "2.0.0" indicatif = "0.16" diff --git a/crates/bindings-csharp/BSATN.Codegen/BSATN.Codegen.csproj b/crates/bindings-csharp/BSATN.Codegen/BSATN.Codegen.csproj index df3238ba713..6edb39ed2d5 100644 --- a/crates/bindings-csharp/BSATN.Codegen/BSATN.Codegen.csproj +++ b/crates/bindings-csharp/BSATN.Codegen/BSATN.Codegen.csproj @@ -2,7 +2,7 @@ SpacetimeDB.BSATN.Codegen - 1.0.0-rc1 + 1.0.0-rc1-hotfix1 SpacetimeDB BSATN Codegen The SpacetimeDB BSATN Codegen implements the Roslyn incremental generators for BSATN serialization/deserialization in C#. diff --git a/crates/bindings-csharp/BSATN.Runtime.Tests/BSATN.Runtime.Tests.csproj b/crates/bindings-csharp/BSATN.Runtime.Tests/BSATN.Runtime.Tests.csproj new file mode 100644 index 00000000000..4abecdfbe7f --- /dev/null +++ b/crates/bindings-csharp/BSATN.Runtime.Tests/BSATN.Runtime.Tests.csproj @@ -0,0 +1,25 @@ + + + + false + true + + + + net8.0 + SpacetimeDB + + + + + + + + + + + + + + + diff --git a/crates/bindings-csharp/BSATN.Runtime.Tests/Tests.cs b/crates/bindings-csharp/BSATN.Runtime.Tests/Tests.cs new file mode 100644 index 00000000000..858bd78753a --- /dev/null +++ b/crates/bindings-csharp/BSATN.Runtime.Tests/Tests.cs @@ -0,0 +1,162 @@ +namespace SpacetimeDB; + +using Xunit; + +public static class BSATNRuntimeTests +{ + [Fact] + public static void AddressRoundtrips() + { + var str = "00112233445566778899AABBCCDDEEFF"; + var addr = Address.FromHexString(str); + + Assert.NotNull(addr); + Assert.Equal(addr.ToString(), str); + + byte[] bytes = + [ + 0x00, + 0x11, + 0x22, + 0x33, + 0x44, + 0x55, + 0x66, + 0x77, + 0x88, + 0x99, + 0xaa, + 0xbb, + 0xcc, + 0xdd, + 0xee, + 0xff, + ]; + var addr2 = Address.FromBigEndian(bytes); + Assert.Equal(addr2, addr); + + Array.Reverse(bytes); + var addr3 = Address.From(bytes); + Assert.Equal(addr3, addr); + + var memoryStream = new MemoryStream(); + var writer = new BinaryWriter(memoryStream); + var bsatn = new Address.BSATN(); + if (addr is { } addrNotNull) + { + bsatn.Write(writer, addrNotNull); + } + else + { + Assert.Fail("Impossible"); + } + writer.Flush(); + + var littleEndianBytes = memoryStream.ToArray(); + var reader = new BinaryReader(new MemoryStream(littleEndianBytes)); + var addr4 = bsatn.Read(reader); + Assert.Equal(addr4, addr); + + // Note: From = FromLittleEndian + var addr5 = Address.From(littleEndianBytes); + Assert.Equal(addr5, addr); + } + + [Fact] + public static void AddressLengthCheck() + { + for (var i = 0; i < 64; i++) + { + if (i == 16) + { + continue; + } + + var bytes = new byte[i]; + + Assert.ThrowsAny(() => Address.From(bytes)); + } + } + + [Fact] + public static void IdentityRoundtrips() + { + var str = "00112233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF"; + var ident = Identity.FromHexString(str); + + Assert.Equal(ident.ToString(), str); + + byte[] bytes = + [ + 0x00, + 0x11, + 0x22, + 0x33, + 0x44, + 0x55, + 0x66, + 0x77, + 0x88, + 0x99, + 0xaa, + 0xbb, + 0xcc, + 0xdd, + 0xee, + 0xff, + 0x00, + 0x11, + 0x22, + 0x33, + 0x44, + 0x55, + 0x66, + 0x77, + 0x88, + 0x99, + 0xaa, + 0xbb, + 0xcc, + 0xdd, + 0xee, + 0xff, + ]; + var ident2 = Identity.FromBigEndian(bytes); + Assert.Equal(ident2, ident); + + Array.Reverse(bytes); + var ident3 = Identity.From(bytes); + Assert.Equal(ident3, ident); + + var memoryStream = new MemoryStream(); + var writer = new BinaryWriter(memoryStream); + var bsatn = new Identity.BSATN(); + bsatn.Write(writer, ident); + writer.Flush(); + + var littleEndianBytes = memoryStream.ToArray(); + var reader = new BinaryReader(new MemoryStream(littleEndianBytes)); + var ident4 = bsatn.Read(reader); + Assert.Equal(ident4, ident); + + // Note: From = FromLittleEndian + var ident5 = Identity.From(littleEndianBytes); + Assert.Equal(ident5, ident); + } + + [Fact] + public static void IdentityLengthCheck() + { + for (var i = 0; i < 64; i++) + { + if (i == 32) + { + continue; + } + + var bytes = new byte[i]; + + Assert.ThrowsAny(() => Identity.From(bytes)); + } + } +} diff --git a/crates/bindings-csharp/BSATN.Runtime/BSATN.Runtime.csproj b/crates/bindings-csharp/BSATN.Runtime/BSATN.Runtime.csproj index 1348bf74685..5b795237723 100644 --- a/crates/bindings-csharp/BSATN.Runtime/BSATN.Runtime.csproj +++ b/crates/bindings-csharp/BSATN.Runtime/BSATN.Runtime.csproj @@ -2,7 +2,7 @@ SpacetimeDB.BSATN.Runtime - 1.0.0-rc1 + 1.0.0-rc1-hotfix1 SpacetimeDB BSATN Runtime The SpacetimeDB BSATN Runtime implements APIs for BSATN serialization/deserialization in C#. diff --git a/crates/bindings-csharp/BSATN.Runtime/Builtins.cs b/crates/bindings-csharp/BSATN.Runtime/Builtins.cs index ee4ca33c999..e8493c4e8a8 100644 --- a/crates/bindings-csharp/BSATN.Runtime/Builtins.cs +++ b/crates/bindings-csharp/BSATN.Runtime/Builtins.cs @@ -8,11 +8,136 @@ namespace SpacetimeDB; internal static class Util { - // Same as `Convert.ToHexString`, but that method is not available in .NET Standard - // which we need to target for Unity support. - public static string ToHex(T val) - where T : struct => - BitConverter.ToString(MemoryMarshal.AsBytes([val]).ToArray()).Replace("-", ""); + /// + /// Convert this object to a BIG-ENDIAN hex string. + /// + /// Big endian is almost always the correct convention here. It puts the most significant bytes + /// of the number at the lowest indexes of the resulting string; assuming the string is printed + /// with low indexes to the left, this will result in the correct hex number being displayed. + /// + /// (This might be wrong if the string is printed after, say, a unicode right-to-left marker. + /// But, well, what can you do.) + /// + /// Similar to `Convert.ToHexString`, but that method is not available in .NET Standard + /// which we need to target for Unity support. + /// + /// + /// + /// + public static string ToHexBigEndian(T val) + where T : struct => BitConverter.ToString(AsBytesBigEndian(val).ToArray()).Replace("-", ""); + + /// + /// Read a value of type T from the passed span, which is assumed to be in little-endian format. + /// The behavior of this method is independent of the endianness of the host, unlike MemoryMarshal.Read. + /// + /// + /// + /// + public static T ReadLittleEndian(ReadOnlySpan source) + where T : struct => Read(source, !BitConverter.IsLittleEndian); + + /// + /// Read a value of type T from the passed span, which is assumed to be in big-endian format. + /// The behavior of this method is independent of the endianness of the host, unlike MemoryMarshal.Read. + /// + /// + /// + /// + public static T ReadBigEndian(ReadOnlySpan source) + where T : struct => Read(source, BitConverter.IsLittleEndian); + + /// + /// Convert the passed byte array to a value of type T, optionally reversing it before performing the conversion. + /// If the input is not reversed, it is treated as having the native endianness of the host system. + /// (The endianness of the host system can be checked via System.BitConverter.IsLittleEndian.) + /// + /// + /// + /// + /// + static T Read(ReadOnlySpan source, bool reverse) + where T : struct + { + if (reverse) + { + Span reversed = stackalloc byte[source.Length]; + source.CopyTo(reversed); + reversed.Reverse(); + return MemoryMarshal.Read(reversed); + } + else + { + return MemoryMarshal.Read(source); + } + } + + /// + /// Convert the passed T to a little-endian byte array. + /// The behavior of this method is independent of the endianness of the host, unlike MemoryMarshal.Read. + /// + /// + /// + /// + public static byte[] AsBytesLittleEndian(T source) + where T : struct => AsBytes(source, !BitConverter.IsLittleEndian); + + /// + /// Convert the passed T to a big-endian byte array. + /// The behavior of this method is independent of the endianness of the host, unlike MemoryMarshal.Read. + /// + /// + /// + /// + public static byte[] AsBytesBigEndian(T source) + where T : struct => AsBytes(source, BitConverter.IsLittleEndian); + + /// + /// Convert the passed T to a byte array, and optionally reverse the array before returning it. + /// If the output is not reversed, it will have the native endianness of the host system. + /// (The endianness of the host system can be checked via System.BitConverter.IsLittleEndian.) + /// + /// + /// + /// + /// + static byte[] AsBytes(T source, bool reverse) + where T : struct + { + var result = MemoryMarshal.AsBytes([source]).ToArray(); + if (reverse) + { + Array.Reverse(result, 0, result.Length); + } + return result; + } + + /// + /// Convert a hex string to a byte array. + /// + /// + /// + public static byte[] StringToByteArray(string hex) + { + var NumberChars = hex.Length; + var bytes = new byte[NumberChars / 2]; + for (var i = 0; i < NumberChars; i += 2) + { + bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16); + } + return bytes; + } + + /// + /// Read a value from a "big-endian" hex string. + /// All hex strings we expect to encounter are big-endian (store most significant bytes + /// at low indexes) so this should always be used. + /// + /// + /// + /// + public static T ReadFromBigEndianHexString(string hex) + where T : struct => ReadBigEndian(StringToByteArray(hex)); } public readonly partial struct Unit @@ -35,10 +160,50 @@ public readonly record struct Address internal Address(U128 v) => value = v; + /// + /// Create an Address from a LITTLE-ENDIAN byte array. + /// + /// If you are parsing an Address from a string, you probably want FromHexString instead, + /// or, failing that, FromBigEndian. + /// + /// Returns null if the resulting address is the default. + /// + /// public static Address? From(byte[] bytes) { Debug.Assert(bytes.Length == 16); - var addr = new Address(MemoryMarshal.Read(bytes)); + var addr = new Address(Util.ReadLittleEndian(bytes)); + return addr == default ? null : addr; + } + + /// + /// Create an Address from a BIG-ENDIAN byte array. + /// + /// This method is the correct choice if you have converted the bytes of a hexadecimal-formatted Address + /// to a byte array in the following way: + /// + /// "0xb0b1b2..." + /// -> + /// [0xb0, 0xb1, 0xb2, ...] + /// + /// Returns null if the resulting address is the default. + /// + /// + public static Address? FromBigEndian(byte[] bytes) + { + Debug.Assert(bytes.Length == 16); + var addr = new Address(Util.ReadBigEndian(bytes)); + return addr == default ? null : addr; + } + + /// + /// Create an Address from a hex string. + /// + /// + /// + public static Address? FromHexString(string hex) + { + var addr = new Address(Util.ReadFromBigEndianHexString(hex)); return addr == default ? null : addr; } @@ -62,7 +227,7 @@ public AlgebraicType GetAlgebraicType(ITypeRegistrar registrar) => new AlgebraicType.Product([new("__address__", new AlgebraicType.U128(default))]); } - public override string ToString() => Util.ToHex(value); + public override string ToString() => Util.ToHexBigEndian(value); } public readonly record struct Identity @@ -71,14 +236,53 @@ public readonly record struct Identity internal Identity(U256 val) => value = val; + /// + /// Create an Identity from a LITTLE-ENDIAN byte array. + /// + /// If you are parsing an Identity from a string, you probably want FromHexString instead, + /// or, failing that, FromBigEndian. + /// + /// public Identity(byte[] bytes) { Debug.Assert(bytes.Length == 32); - value = MemoryMarshal.Read(bytes); + value = Util.ReadLittleEndian(bytes); } + /// + /// Create an Identity from a LITTLE-ENDIAN byte array. + /// + /// If you are parsing an Identity from a string, you probably want FromHexString instead, + /// or, failing that, FromBigEndian. + /// + /// public static Identity From(byte[] bytes) => new(bytes); + /// + /// Create an Identity from a BIG-ENDIAN byte array. + /// + /// This method is the correct choice if you have converted the bytes of a hexadecimal-formatted `Identity` + /// to a byte array in the following way: + /// + /// "0xb0b1b2..." + /// -> + /// [0xb0, 0xb1, 0xb2, ...] + /// + /// + public static Identity FromBigEndian(byte[] bytes) + { + Debug.Assert(bytes.Length == 32); + return new Identity(Util.ReadBigEndian(bytes)); + } + + /// + /// Create an Identity from a hex string. + /// + /// + /// + public static Identity FromHexString(string hex) => + new Identity(Util.ReadFromBigEndianHexString(hex)); + public readonly struct BSATN : IReadWrite { public Identity Read(BinaryReader reader) => new(new SpacetimeDB.BSATN.U256().Read(reader)); @@ -91,35 +295,35 @@ public AlgebraicType GetAlgebraicType(ITypeRegistrar registrar) => } // This must be explicitly forwarded to base, otherwise record will generate a new implementation. - public override string ToString() => Util.ToHex(value); + public override string ToString() => Util.ToHexBigEndian(value); } // [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 { [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(), }; @@ -129,8 +333,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(), } ); @@ -141,8 +345,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)), ] ); } diff --git a/crates/bindings-csharp/Codegen/Codegen.csproj b/crates/bindings-csharp/Codegen/Codegen.csproj index 85de5f1f9d8..a0ceb9ec7b0 100644 --- a/crates/bindings-csharp/Codegen/Codegen.csproj +++ b/crates/bindings-csharp/Codegen/Codegen.csproj @@ -2,7 +2,7 @@ SpacetimeDB.Codegen - 1.0.0-rc1 + 1.0.0-rc1-hotfix1 SpacetimeDB Module Codegen The SpacetimeDB Codegen implements the Roslyn incremental generators for writing SpacetimeDB modules in C#. diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawRowLevelSecurityDefV9.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawRowLevelSecurityDefV9.cs index 81c75282e85..9b8100d0741 100644 --- a/crates/bindings-csharp/Runtime/Internal/Autogen/RawRowLevelSecurityDefV9.cs +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawRowLevelSecurityDefV9.cs @@ -18,9 +18,7 @@ public partial class RawRowLevelSecurityDefV9 [DataMember(Name = "sql")] public string Sql; - public RawRowLevelSecurityDefV9( - string Sql - ) + public RawRowLevelSecurityDefV9(string Sql) { this.Sql = Sql; } diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawUniqueConstraintDataV9.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawUniqueConstraintDataV9.cs index 35abef5e88e..b02f8dc7e41 100644 --- a/crates/bindings-csharp/Runtime/Internal/Autogen/RawUniqueConstraintDataV9.cs +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawUniqueConstraintDataV9.cs @@ -18,9 +18,7 @@ public partial class RawUniqueConstraintDataV9 [DataMember(Name = "columns")] public System.Collections.Generic.List Columns; - public RawUniqueConstraintDataV9( - System.Collections.Generic.List Columns - ) + public RawUniqueConstraintDataV9(System.Collections.Generic.List Columns) { this.Columns = Columns; } diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/Typespace.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/Typespace.cs index d9978916278..bf7112ca5bd 100644 --- a/crates/bindings-csharp/Runtime/Internal/Autogen/Typespace.cs +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/Typespace.cs @@ -18,9 +18,7 @@ public partial class Typespace [DataMember(Name = "types")] public System.Collections.Generic.List Types; - public Typespace( - System.Collections.Generic.List Types - ) + public Typespace(System.Collections.Generic.List Types) { this.Types = Types; } diff --git a/crates/bindings-csharp/Runtime/Runtime.csproj b/crates/bindings-csharp/Runtime/Runtime.csproj index 8ab709f19f3..011a41b3961 100644 --- a/crates/bindings-csharp/Runtime/Runtime.csproj +++ b/crates/bindings-csharp/Runtime/Runtime.csproj @@ -2,7 +2,7 @@ SpacetimeDB.Runtime - 1.0.0-rc1 + 1.0.0-rc1-hotfix1 SpacetimeDB Module Runtime The SpacetimeDB Runtime implements the database runtime bindings for writing SpacetimeDB modules in C#. diff --git a/crates/bindings-csharp/SpacetimeSharpSATS.sln b/crates/bindings-csharp/SpacetimeSharpSATS.sln index 4e49b92f77b..737bb0981c2 100644 --- a/crates/bindings-csharp/SpacetimeSharpSATS.sln +++ b/crates/bindings-csharp/SpacetimeSharpSATS.sln @@ -28,6 +28,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sdk-tests", "sdk-tests", "{ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "benchmarks-cs", "..\..\modules\benchmarks-cs\benchmarks-cs.csproj", "{50E1AAE1-C42C-4C2F-B708-5190B0362165}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BSATN.Runtime.Tests", "BSATN.Runtime.Tests\BSATN.Runtime.Tests.csproj", "{FCF18E21-FB59-4A4D-A9ED-B85D2874E536}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -62,6 +64,10 @@ Global {FDACD960-168E-44F9-B036-2E29EA391BE7}.Release|Any CPU.ActiveCfg = Release|Any CPU {50E1AAE1-C42C-4C2F-B708-5190B0362165}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {50E1AAE1-C42C-4C2F-B708-5190B0362165}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FCF18E21-FB59-4A4D-A9ED-B85D2874E536}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FCF18E21-FB59-4A4D-A9ED-B85D2874E536}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FCF18E21-FB59-4A4D-A9ED-B85D2874E536}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FCF18E21-FB59-4A4D-A9ED-B85D2874E536}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/crates/bindings-macro/src/lib.rs b/crates/bindings-macro/src/lib.rs index 07a88e18eec..8357650559c 100644 --- a/crates/bindings-macro/src/lib.rs +++ b/crates/bindings-macro/src/lib.rs @@ -45,6 +45,7 @@ mod sym { symbol!(public); symbol!(sats); symbol!(scheduled); + symbol!(scheduled_at); symbol!(unique); symbol!(update); @@ -154,7 +155,7 @@ mod sym { pub fn reducer(args: StdTokenStream, item: StdTokenStream) -> StdTokenStream { cvt_attr::(args, item, quote!(), |args, original_function| { let args = reducer::ReducerArgs::parse(args)?; - reducer::reducer_impl(args, &original_function) + reducer::reducer_impl(args, original_function) }) } @@ -241,7 +242,7 @@ pub fn table(args: StdTokenStream, item: StdTokenStream) -> StdTokenStream { /// Provides helper attributes for `#[spacetimedb::table]`, so that we don't get unknown attribute errors. #[doc(hidden)] -#[proc_macro_derive(__TableHelper, attributes(sats, unique, auto_inc, primary_key, index))] +#[proc_macro_derive(__TableHelper, attributes(sats, unique, auto_inc, primary_key, index, scheduled_at))] pub fn table_helper(_input: StdTokenStream) -> StdTokenStream { Default::default() } diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index 004e512e512..1bb6ddbf1f3 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1,6 +1,6 @@ use crate::sats::{self, derive_deserialize, derive_satstype, derive_serialize}; use crate::sym; -use crate::util::{check_duplicate, check_duplicate_msg, ident_to_litstr, match_meta, MutItem}; +use crate::util::{check_duplicate, check_duplicate_msg, ident_to_litstr, match_meta}; use heck::ToSnakeCase; use proc_macro2::{Span, TokenStream}; use quote::{format_ident, quote, quote_spanned, ToTokens}; @@ -36,21 +36,6 @@ impl TableAccess { } } -// add scheduled_id and scheduled_at fields to the struct -fn add_scheduled_fields(item: &mut syn::DeriveInput) { - if let syn::Data::Struct(struct_data) = &mut item.data { - if let syn::Fields::Named(fields) = &mut struct_data.fields { - let extra_fields: syn::FieldsNamed = parse_quote!({ - #[primary_key] - #[auto_inc] - pub scheduled_id: u64, - pub scheduled_at: spacetimedb::spacetimedb_lib::ScheduleAt, - }); - fields.named.extend(extra_fields.named); - } - } -} - struct IndexArg { name: Ident, kind: IndexType, @@ -365,6 +350,7 @@ enum ColumnAttr { AutoInc(Span), PrimaryKey(Span), Index(IndexArg), + ScheduledAt(Span), } impl ColumnAttr { @@ -384,23 +370,18 @@ impl ColumnAttr { } else if ident == sym::primary_key { attr.meta.require_path_only()?; Some(ColumnAttr::PrimaryKey(ident.span())) + } else if ident == sym::scheduled_at { + attr.meta.require_path_only()?; + Some(ColumnAttr::ScheduledAt(ident.span())) } else { None }) } } -pub(crate) fn table_impl(mut args: TableArgs, mut item: MutItem) -> syn::Result { - let scheduled_reducer_type_check = args.scheduled.as_ref().map(|reducer| { - add_scheduled_fields(&mut item); - let struct_name = &item.ident; - quote! { - const _: () = spacetimedb::rt::scheduled_reducer_typecheck::<#struct_name>(#reducer); - } - }); - +pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::Result { let vis = &item.vis; - let sats_ty = sats::sats_type_from_derive(&item, quote!(spacetimedb::spacetimedb_lib))?; + let sats_ty = sats::sats_type_from_derive(item, quote!(spacetimedb::spacetimedb_lib))?; let original_struct_ident = sats_ty.ident; let table_ident = &args.name; @@ -429,7 +410,7 @@ pub(crate) fn table_impl(mut args: TableArgs, mut item: MutItem u16::MAX.into() { return Err(syn::Error::new_spanned( - &*item, + item, "too many columns; the most a table can have is 2^16", )); } @@ -438,6 +419,7 @@ pub(crate) fn table_impl(mut args: TableArgs, mut item: MutItem args.indices.push(index_arg), + ColumnAttr::ScheduledAt(span) => { + check_duplicate(&scheduled_at, span)?; + scheduled_at = Some(span); + } } } @@ -489,10 +476,27 @@ pub(crate) fn table_impl(mut args: TableArgs, mut item: MutItem();) + }); + let row_type = quote!(#original_struct_ident); let mut indices = args @@ -543,17 +547,46 @@ pub(crate) fn table_impl(mut args: TableArgs, mut item: MutItem(#reducer); + } + }); let schedule = args .scheduled .as_ref() .map(|reducer| { - // scheduled_at was inserted as the last field - let scheduled_at_id = (fields.len() - 1) as u16; - quote!(spacetimedb::table::ScheduleDesc { + // better error message when both are missing + if scheduled_at_column.is_none() && primary_key_column.is_none() { + return Err(syn::Error::new( + original_struct_ident.span(), + "scheduled table missing required columns; add these to your struct:\n\ + #[primary_key]\n\ + #[auto_inc]\n\ + scheduled_id: u64,\n\ + #[scheduled_at]\n\ + scheduled_at: spacetimedb::ScheduleAt,", + )); + } + let scheduled_at_column = scheduled_at_column.ok_or_else(|| { + syn::Error::new( + original_struct_ident.span(), + "scheduled tables must have a `#[scheduled_at] scheduled_at: spacetimedb::ScheduleAt` column.", + ) + })?; + let scheduled_at_id = scheduled_at_column.index; + if primary_key_column.is_none() { + return Err(syn::Error::new( + original_struct_ident.span(), + "scheduled tables should have a `#[primary_key] #[auto_inc] scheduled_id: u64` column", + )); + } + Ok(quote!(spacetimedb::table::ScheduleDesc { reducer_name: <#reducer as spacetimedb::rt::ReducerInfo>::NAME, scheduled_at_column: #scheduled_at_id, - }) + })) }) + .transpose()? .into_iter(); let unique_err = if !unique_columns.is_empty() { @@ -567,7 +600,6 @@ pub(crate) fn table_impl(mut args: TableArgs, mut item: MutItem>(); let field_types = fields.iter().map(|f| f.ty).collect::>(); let tabletype_impl = quote! { @@ -602,16 +634,6 @@ pub(crate) fn table_impl(mut args: TableArgs, mut item: MutItem for #original_struct_ident { - type Field = #field_types; - fn get_field(&self) -> &Self::Field { - &self.#field_names - } - })* - }; - let row_type_to_table = quote!(<#row_type as spacetimedb::table::__MapRowTypeToTable>::Table); // Output all macro data @@ -638,6 +660,9 @@ pub(crate) fn table_impl(mut args: TableArgs, mut item: MutItem::_ITEM;)* + #scheduled_reducer_type_check + #scheduled_at_typecheck + #scheduled_id_typecheck }; #trait_def @@ -672,10 +697,6 @@ pub(crate) fn table_impl(mut args: TableArgs, mut item: MutItem( args: StdTokenStream, item: StdTokenStream, extra_attr: TokenStream, - f: impl FnOnce(TokenStream, MutItem<'_, Item>) -> syn::Result, + f: impl FnOnce(TokenStream, &Item) -> syn::Result, ) -> StdTokenStream { let item: TokenStream = item.into(); - let mut parsed_item = match syn::parse2::(item.clone()) { + let parsed_item = match syn::parse2::(item.clone()) { Ok(i) => i, Err(e) => return TokenStream::from_iter([item, e.into_compile_error()]).into(), }; - let mut modified = false; - let mut_item = MutItem { - val: &mut parsed_item, - modified: &mut modified, - }; - let generated = f(args.into(), mut_item).unwrap_or_else(syn::Error::into_compile_error); - let item = if modified { - parsed_item.into_token_stream() - } else { - item - }; + let generated = f(args.into(), &parsed_item).unwrap_or_else(syn::Error::into_compile_error); TokenStream::from_iter([extra_attr, item, generated]).into() } @@ -35,23 +25,6 @@ pub(crate) fn ident_to_litstr(ident: &Ident) -> syn::LitStr { syn::LitStr::new(&ident.to_string(), ident.span()) } -pub(crate) struct MutItem<'a, T> { - val: &'a mut T, - modified: &'a mut bool, -} -impl std::ops::Deref for MutItem<'_, T> { - type Target = T; - fn deref(&self) -> &Self::Target { - self.val - } -} -impl std::ops::DerefMut for MutItem<'_, T> { - fn deref_mut(&mut self) -> &mut Self::Target { - *self.modified = true; - self.val - } -} - pub(crate) trait ErrorSource { fn error(self, msg: impl std::fmt::Display) -> syn::Error; } diff --git a/crates/bindings/src/rt.rs b/crates/bindings/src/rt.rs index 1d9d53111a8..5618823accd 100644 --- a/crates/bindings/src/rt.rs +++ b/crates/bindings/src/rt.rs @@ -437,17 +437,21 @@ extern "C" fn __describe_module__(description: BytesSink) { /// when the `sender` calls the reducer identified by `id` at `timestamp` with `args`. /// /// The `sender_{0-3}` are the pieces of a `[u8; 32]` (`u256`) representing the sender's `Identity`. -/// They are encoded as follows (assuming `identity.identity_bytes: [u8; 32]`): +/// They are encoded as follows (assuming `identity.to_byte_array(): [u8; 32]`): /// - `sender_0` contains bytes `[0 ..8 ]`. /// - `sender_1` contains bytes `[8 ..16]`. /// - `sender_2` contains bytes `[16..24]`. /// - `sender_3` contains bytes `[24..32]`. /// +/// Note that `to_byte_array` uses LITTLE-ENDIAN order! This matches most host systems. +/// /// The `address_{0-1}` are the pieces of a `[u8; 16]` (`u128`) representing the callers's `Address`. -/// They are encoded as follows (assuming `address.__address__: u128`): +/// They are encoded as follows (assuming `address.as_byte_array(): [u8; 16]`): /// - `address_0` contains bytes `[0 ..8 ]`. /// - `address_1` contains bytes `[8 ..16]`. /// +/// Again, note that `to_byte_array` uses LITTLE-ENDIAN order! This matches most host systems. +/// /// The `args` is a `BytesSource`, registered on the host side, /// which can be read with `bytes_source_read`. /// The contents of the buffer are the BSATN-encoding of the arguments to the reducer. @@ -475,13 +479,13 @@ extern "C" fn __call_reducer__( // Piece together `sender_i` into an `Identity`. let sender = [sender_0, sender_1, sender_2, sender_3]; let sender: [u8; 32] = bytemuck::must_cast(sender); - let sender = Identity::from_byte_array(sender); + let sender = Identity::from_byte_array(sender); // The LITTLE-ENDIAN constructor. // Piece together `address_i` into an `Address`. // The all-zeros `address` (`Address::__DUMMY`) is interpreted as `None`. let address = [address_0, address_1]; let address: [u8; 16] = bytemuck::must_cast(address); - let address = Address::from_byte_array(address); + let address = Address::from_byte_array(address); // The LITTLE-ENDIAN constructor. let address = (address != Address::__DUMMY).then_some(address); // Assemble the `ReducerContext`. diff --git a/crates/bindings/src/table.rs b/crates/bindings/src/table.rs index 2e8a1256a72..0ae6355d574 100644 --- a/crates/bindings/src/table.rs +++ b/crates/bindings/src/table.rs @@ -262,19 +262,6 @@ impl MaybeError for AutoIncOverflow { } } -/// A trait for types exposing an operation to access their `N`th field. -/// -/// In other words, a type implementing `FieldAccess` allows -/// shared projection from `self` to its `N`th field. -#[doc(hidden)] -pub trait FieldAccess { - /// The type of the field at the `N`th position. - type Field; - - /// Project to the value of the field at position `N`. - fn get_field(&self) -> &Self::Field; -} - pub trait Column { type Row; type ColType; diff --git a/crates/bindings/tests/ui/reducers.rs b/crates/bindings/tests/ui/reducers.rs index 782f6355248..404a4c588cc 100644 --- a/crates/bindings/tests/ui/reducers.rs +++ b/crates/bindings/tests/ui/reducers.rs @@ -25,8 +25,22 @@ fn missing_ctx(_a: u8) {} #[spacetimedb::reducer] fn ctx_by_val(_ctx: ReducerContext, _a: u8) {} +#[spacetimedb::table(name = scheduled_table_missing_rows, scheduled(scheduled_table_missing_rows_reducer))] +struct ScheduledTableMissingRows { + x: u8, + y: u8, +} + +// #[spacetimedb::reducer] +// fn scheduled_table_missing_rows_reducer(_ctx: &ReducerContext, _: &ScheduledTableMissingRows) {} + #[spacetimedb::table(name = scheduled_table, scheduled(scheduled_table_reducer))] struct ScheduledTable { + #[primary_key] + #[auto_inc] + scheduled_id: u64, + #[scheduled_at] + scheduled_at: spacetimedb::ScheduleAt, x: u8, y: u8, } diff --git a/crates/bindings/tests/ui/reducers.stderr b/crates/bindings/tests/ui/reducers.stderr index bb48b5a371b..c8277182b03 100644 --- a/crates/bindings/tests/ui/reducers.stderr +++ b/crates/bindings/tests/ui/reducers.stderr @@ -10,16 +10,27 @@ error: const parameters are not allowed on reducers 20 | fn const_param() {} | ^^^^^^^^^^^ +error: scheduled table missing required columns; add these to your struct: + #[primary_key] + #[auto_inc] + scheduled_id: u64, + #[scheduled_at] + scheduled_at: spacetimedb::ScheduleAt, + --> tests/ui/reducers.rs:29:8 + | +29 | struct ScheduledTableMissingRows { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0593]: function is expected to take 2 arguments, but it takes 3 arguments - --> tests/ui/reducers.rs:28:56 + --> tests/ui/reducers.rs:37:56 | -28 | #[spacetimedb::table(name = scheduled_table, scheduled(scheduled_table_reducer))] +37 | #[spacetimedb::table(name = scheduled_table, scheduled(scheduled_table_reducer))] | -------------------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^--- | | | | | expected function that takes 2 arguments | required by a bound introduced by this call ... -35 | fn scheduled_table_reducer(_ctx: &ReducerContext, _x: u8, _y: u8) {} +49 | fn scheduled_table_reducer(_ctx: &ReducerContext, _x: u8, _y: u8) {} | ----------------------------------------------------------------- takes 3 arguments | = note: required for `for<'a> fn(&'a ReducerContext, u8, u8) {scheduled_table_reducer}` to implement `Reducer<'_, (ScheduledTable,)>` diff --git a/crates/cli/src/subcommands/generate/csharp.rs b/crates/cli/src/subcommands/generate/csharp.rs index 5758bf69d60..fba9ef18d45 100644 --- a/crates/cli/src/subcommands/generate/csharp.rs +++ b/crates/cli/src/subcommands/generate/csharp.rs @@ -6,7 +6,7 @@ use std::ops::Deref; use convert_case::{Case, Casing}; use spacetimedb_lib::sats::{AlgebraicType, AlgebraicTypeRef, ArrayType, ProductType, SumType}; -use spacetimedb_lib::ReducerDef; +use spacetimedb_lib::{ProductTypeElement, ReducerDef}; use spacetimedb_primitives::ColList; use spacetimedb_schema::def::{BTreeAlgorithm, IndexAlgorithm}; use spacetimedb_schema::schema::TableSchema; @@ -265,26 +265,25 @@ pub fn autogen_csharp_sum(ctx: &GenCtx, name: &str, sum_type: &SumType, namespac } pub fn autogen_csharp_tuple(ctx: &GenCtx, name: &str, tuple: &ProductType, namespace: &str) -> String { - autogen_csharp_product_table_common(ctx, name, tuple, None, namespace) + autogen_csharp_product_common_file(ctx, name, &tuple.elements, "", namespace) } #[allow(deprecated)] pub fn autogen_csharp_table(ctx: &GenCtx, table: &TableDescHack, namespace: &str) -> String { - let tuple = ctx.typespace[table.data].as_product().unwrap(); - autogen_csharp_product_table_common( + autogen_csharp_product_common_file( ctx, csharp_typename(ctx, table.data), - tuple, - Some(table.schema.clone()), + &ctx.typespace[table.data].as_product().unwrap().elements, + "IDatabaseRow", namespace, ) } -fn autogen_csharp_product_table_common( +fn autogen_csharp_product_common_file( ctx: &GenCtx, name: &str, - product_type: &ProductType, - schema: Option, + product_type_elems: &[ProductTypeElement], + base: &str, namespace: &str, ) -> String { let mut output = CsharpAutogen::new( @@ -292,16 +291,29 @@ fn autogen_csharp_product_table_common( &["System.Collections.Generic", "System.Runtime.Serialization"], ); + autogen_csharp_product_common(ctx, &mut output, name, product_type_elems, base, namespace, |_| {}); + + output.into_inner() +} + +fn autogen_csharp_product_common( + ctx: &GenCtx, + output: &mut CodeIndenter, + name: &str, + product_type_elems: &[ProductTypeElement], + base: &str, + namespace: &str, + extra_body: impl FnOnce(&mut CodeIndenter), +) { writeln!(output, "[SpacetimeDB.Type]"); writeln!(output, "[DataContract]"); write!(output, "public partial class {name}"); - if schema.is_some() { - write!(output, " : IDatabaseRow"); + if !base.is_empty() { + write!(output, " : {base}"); } writeln!(output); - indented_block(&mut output, |output| { - let fields = product_type - .elements + indented_block(output, |output| { + let fields = product_type_elems .iter() .map(|field| { let orig_name = field @@ -321,32 +333,38 @@ fn autogen_csharp_product_table_common( }) .collect::>(); - // Generate fully-parameterized constructor. - writeln!(output); - writeln!(output, "public {name}("); - { - indent_scope!(output); - for (i, (field_name, ty)) in fields.iter().enumerate() { - if i != 0 { - writeln!(output, ","); + // If we don't have any fields, the default constructor is fine, otherwise we need to generate our own. + if !fields.is_empty() { + // Generate fully-parameterized constructor. + writeln!(output); + write!(output, "public {name}("); + if fields.len() > 1 { + writeln!(output); + } + { + indent_scope!(output); + for (i, (field_name, ty)) in fields.iter().enumerate() { + if i != 0 { + writeln!(output, ","); + } + write!(output, "{ty} {field_name}"); } - write!(output, "{ty} {field_name}"); } - } - writeln!(output); - writeln!(output, ")"); - indented_block(output, |output| { - for (field_name, _ty) in fields.iter() { - writeln!(output, "this.{field_name} = {field_name};"); + if fields.len() > 1 { + writeln!(output); } - }); - writeln!(output); + writeln!(output, ")"); + indented_block(output, |output| { + for (field_name, _ty) in fields.iter() { + writeln!(output, "this.{field_name} = {field_name};"); + } + }); + writeln!(output); - // Generate default constructor (if the one above is not already parameterless). - if !fields.is_empty() { + // Generate default constructor. writeln!(output, "public {name}()"); indented_block(output, |output| { - for ((field_name, _ty), field) in fields.iter().zip(&*product_type.elements) { + for ((field_name, _ty), field) in fields.iter().zip(product_type_elems) { if let Some(default) = default_init(ctx, &field.algebraic_type) { writeln!(output, "this.{field_name} = {default};"); } @@ -354,9 +372,9 @@ fn autogen_csharp_product_table_common( }); writeln!(output); } - }); - output.into_inner() + extra_body(output); + }); } fn indented_block(output: &mut CodeIndenter, f: impl FnOnce(&mut CodeIndenter) -> R) -> R { @@ -505,40 +523,6 @@ fn autogen_csharp_access_funcs_for_struct( } } -pub fn autogen_csharp_reducer(ctx: &GenCtx, reducer: &ReducerDef, namespace: &str) -> String { - let func_name = &*reducer.name; - let func_name_pascal_case = func_name.to_case(Case::Pascal); - - let mut output = CsharpAutogen::new(namespace, &[]); - - //Args struct - writeln!(output, "[SpacetimeDB.Type]"); - writeln!(output, "public partial class {func_name_pascal_case} : IReducerArgs"); - indented_block(&mut output, |output| { - writeln!(output, "string IReducerArgs.ReducerName => \"{func_name}\";"); - if !reducer.args.is_empty() { - writeln!(output); - } - for arg in reducer.args.iter() { - let name = arg - .name - .as_deref() - .unwrap_or_else(|| panic!("reducer args should have names: {func_name}")); - let arg_type_str = ty_fmt(ctx, &arg.algebraic_type, namespace); - let field_name = name.to_case(Case::Pascal); - - write!(output, "public {arg_type_str} {field_name}"); - // Skip default initializer if it's the same as the implicit default. - if let Some(default) = default_init(ctx, &arg.algebraic_type) { - write!(output, " = {default}"); - } - writeln!(output, ";"); - } - }); - - output.into_inner() -} - pub fn autogen_csharp_globals(ctx: &GenCtx, items: &[GenItem], namespace: &str) -> Vec<(String, String)> { let mut results = Vec::new(); @@ -565,7 +549,14 @@ pub fn autogen_csharp_globals(ctx: &GenCtx, items: &[GenItem], namespace: &str) .map(|reducer| reducer.name.deref().to_case(Case::Pascal)) .collect(); - let mut output = CsharpAutogen::new(namespace, &["SpacetimeDB.ClientApi", "System.Collections.Generic"]); + let mut output = CsharpAutogen::new( + namespace, + &[ + "SpacetimeDB.ClientApi", + "System.Collections.Generic", + "System.Runtime.Serialization", + ], + ); writeln!(output, "public sealed class RemoteTables"); indented_block(&mut output, |output| { @@ -653,12 +644,12 @@ pub fn autogen_csharp_globals(ctx: &GenCtx, items: &[GenItem], namespace: &str) let delegate_separator = if !reducer.args.is_empty() { ", " } else { "" }; let mut func_params: String = String::new(); - let mut field_inits: String = String::new(); + let mut func_args: String = String::new(); for (arg_i, arg) in reducer.args.iter().enumerate() { if arg_i != 0 { func_params.push_str(", "); - field_inits.push_str(", "); + func_args.push_str(", "); } let name = arg @@ -667,10 +658,9 @@ pub fn autogen_csharp_globals(ctx: &GenCtx, items: &[GenItem], namespace: &str) .unwrap_or_else(|| panic!("reducer args should have names: {func_name}")); let arg_type_str = ty_fmt(ctx, &arg.algebraic_type, namespace); let arg_name = name.to_case(Case::Camel); - let field_name = name.to_case(Case::Pascal); write!(func_params, "{arg_type_str} {arg_name}").unwrap(); - write!(field_inits, "{field_name} = {arg_name}").unwrap(); + write!(func_args, "{arg_name}").unwrap(); } writeln!( @@ -687,14 +677,14 @@ pub fn autogen_csharp_globals(ctx: &GenCtx, items: &[GenItem], namespace: &str) indented_block(output, |output| { writeln!( output, - "conn.InternalCallReducer(new {func_name_pascal_case} {{ {field_inits} }}, this.SetCallReducerFlags.{func_name_pascal_case}Flags);" + "conn.InternalCallReducer(new Reducer.{func_name_pascal_case}({func_args}), this.SetCallReducerFlags.{func_name_pascal_case}Flags);" ); }); writeln!(output); writeln!( output, - "public bool Invoke{func_name_pascal_case}(EventContext ctx, {func_name_pascal_case} args)" + "public bool Invoke{func_name_pascal_case}(EventContext ctx, Reducer.{func_name_pascal_case} args)" ); indented_block(output, |output| { writeln!(output, "if (On{func_name_pascal_case} == null) return false;"); @@ -753,18 +743,31 @@ pub fn autogen_csharp_globals(ctx: &GenCtx, items: &[GenItem], namespace: &str) }); writeln!(output); - writeln!(output, "[Type]"); - writeln!(output, "public partial record Reducer : TaggedEnum<("); - { - indent_scope!(output); - for reducer_name in &reducer_names { - writeln!(output, "{reducer_name} {reducer_name},"); + writeln!(output, "public abstract partial class Reducer"); + indented_block(&mut output, |output| { + // Prevent instantiation of this class from outside. + writeln!(output, "private Reducer() {{ }}"); + writeln!(output); + for (reducer, reducer_name) in std::iter::zip(&reducers, &reducer_names) { + let reducer_str_name = &reducer.name; + autogen_csharp_product_common( + ctx, + output, + reducer_name, + &reducer.args, + "Reducer, IReducerArgs", + namespace, + |output| { + writeln!(output, "string IReducerArgs.ReducerName => \"{reducer_str_name}\";"); + }, + ); + writeln!(output); } - writeln!(output, "Unit StdbNone,"); - writeln!(output, "Unit StdbIdentityConnected,"); - writeln!(output, "Unit StdbIdentityDisconnected"); - } - writeln!(output, ")>;"); + writeln!(output, "public class StdbNone : Reducer {{}}"); + writeln!(output, "public class StdbIdentityConnected : Reducer {{}}"); + writeln!(output, "public class StdbIdentityDisconnected : Reducer {{}}"); + }); + writeln!(output); writeln!( output, @@ -806,19 +809,19 @@ pub fn autogen_csharp_globals(ctx: &GenCtx, items: &[GenItem], namespace: &str) let reducer_str_name = &reducer.name; writeln!( output, - "\"{reducer_str_name}\" => new Reducer.{reducer_name}(BSATNHelpers.Decode<{reducer_name}>(encodedArgs))," + "\"{reducer_str_name}\" => BSATNHelpers.Decode(encodedArgs)," ); } - writeln!(output, "\"\" => new Reducer.StdbNone(default),"); + writeln!(output, "\"\" => new Reducer.StdbNone(),"); writeln!( output, - "\"__identity_connected__\" => new Reducer.StdbIdentityConnected(default)," + "\"__identity_connected__\" => new Reducer.StdbIdentityConnected()," ); writeln!( output, - "\"__identity_disconnected__\" => new Reducer.StdbIdentityDisconnected(default)," + "\"__identity_disconnected__\" => new Reducer.StdbIdentityDisconnected()," ); - writeln!(output, "\"\" => new Reducer.StdbNone(default),"); //Transaction from CLI command + writeln!(output, "\"\" => new Reducer.StdbNone(),"); //Transaction from CLI command writeln!( output, r#"var reducer => throw new ArgumentOutOfRangeException("Reducer", $"Unknown reducer {{reducer}}")"# @@ -847,7 +850,7 @@ pub fn autogen_csharp_globals(ctx: &GenCtx, items: &[GenItem], namespace: &str) for reducer_name in &reducer_names { writeln!( output, - "Reducer.{reducer_name}(var args) => Reducers.Invoke{reducer_name}(eventContext, args)," + "Reducer.{reducer_name} args => Reducers.Invoke{reducer_name}(eventContext, args)," ); } writeln!(output, "Reducer.StdbNone or"); diff --git a/crates/cli/src/subcommands/generate/mod.rs b/crates/cli/src/subcommands/generate/mod.rs index f5d6d232526..38a9cb5dfec 100644 --- a/crates/cli/src/subcommands/generate/mod.rs +++ b/crates/cli/src/subcommands/generate/mod.rs @@ -19,7 +19,6 @@ use spacetimedb_schema::def::{ModuleDef, ReducerDef, ScopedTypeName, TableDef, T use spacetimedb_schema::identifier::Identifier; use spacetimedb_schema::schema::{Schema, TableSchema}; use std::fs; -use std::ops::Deref; use std::path::{Path, PathBuf}; use wasmtime::{Caller, StoreContextMut}; @@ -365,11 +364,7 @@ impl GenItem { } _ => todo!(), }, - GenItem::Reducer(reducer) => { - let code = csharp::autogen_csharp_reducer(ctx, reducer, namespace); - let pascalcase = reducer.name.deref().to_case(Case::Pascal); - Some((pascalcase + "Reducer.cs", code)) - } + GenItem::Reducer(_) => None, } } } diff --git a/crates/cli/src/subcommands/generate/rust.rs b/crates/cli/src/subcommands/generate/rust.rs index b44c9dd47b8..f948c6760ff 100644 --- a/crates/cli/src/subcommands/generate/rust.rs +++ b/crates/cli/src/subcommands/generate/rust.rs @@ -1,5 +1,5 @@ use super::code_indenter::{CodeIndenter, Indenter}; -use super::util::{collect_case, print_lines, type_ref_name}; +use super::util::{collect_case, is_type_filterable, print_lines, type_ref_name}; use super::Lang; use crate::generate::util::{namespace_is_empty_or_default, print_auto_generated_file_comment}; use convert_case::{Case, Casing}; @@ -9,7 +9,7 @@ use spacetimedb_primitives::ColList; use spacetimedb_schema::def::{ModuleDef, ReducerDef, ScopedTypeName, TableDef, TypeDef}; use spacetimedb_schema::identifier::Identifier; use spacetimedb_schema::schema::{Schema, TableSchema}; -use spacetimedb_schema::type_for_generate::{AlgebraicTypeDef, AlgebraicTypeUse, PrimitiveType}; +use spacetimedb_schema::type_for_generate::{AlgebraicTypeDef, AlgebraicTypeUse, PrimitiveType, ProductTypeDef}; use std::collections::BTreeSet; use std::fmt::{self, Write}; use std::ops::Deref; @@ -59,7 +59,7 @@ Requested namespace: {namespace}", AlgebraicTypeDef::Product(product) => { gen_and_print_imports(module, out, &product.elements, &[typ.ty]); out.newline(); - define_struct_for_product(module, out, &type_name, &product.elements); + define_struct_for_product(module, out, &type_name, &product.elements, "pub"); } AlgebraicTypeDef::Sum(sum) => { gen_and_print_imports(module, out, &sum.variants, &[typ.ty]); @@ -81,7 +81,7 @@ Requested namespace: {namespace}", writeln!( out, " -impl __sdk::spacetime_module::InModule for {type_name} {{ +impl __sdk::InModule for {type_name} {{ type Module = super::RemoteModule; }} ", @@ -130,7 +130,7 @@ Requested namespace: {namespace}", let table_handle = table_name_pascalcase.clone() + "TableHandle"; let insert_callback_id = table_name_pascalcase.clone() + "InsertCallbackId"; let delete_callback_id = table_name_pascalcase.clone() + "DeleteCallbackId"; - let accessor_trait = table_name_pascalcase.clone() + "TableAccess"; + let accessor_trait = table_access_trait_name(&table.name); let accessor_method = table_method_name(&table.name); write!( @@ -145,7 +145,7 @@ Requested namespace: {namespace}", /// but to directly chain method calls, /// like `ctx.db.{accessor_method}().on_insert(...)`. pub struct {table_handle}<'ctx> {{ - imp: __sdk::db_connection::TableHandle<{row_type}>, + imp: __sdk::TableHandle<{row_type}>, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, }} @@ -168,10 +168,10 @@ impl {accessor_trait} for super::RemoteTables {{ }} }} -pub struct {insert_callback_id}(__sdk::callbacks::CallbackId); -pub struct {delete_callback_id}(__sdk::callbacks::CallbackId); +pub struct {insert_callback_id}(__sdk::CallbackId); +pub struct {delete_callback_id}(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for {table_handle}<'ctx> {{ +impl<'ctx> __sdk::Table for {table_handle}<'ctx> {{ type Row = {row_type}; type EventContext = super::EventContext; @@ -207,6 +207,25 @@ impl<'ctx> __sdk::table::Table for {table_handle}<'ctx> {{ " ); + out.delimited_block( + " +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { +", + |out| { + writeln!(out, "let _table = client_cache.get_or_make_table::<{row_type}>({table_name:?});"); + for (unique_field_ident, unique_field_type_use) in iter_unique_cols(&schema, product_def) { + let unique_field_name = unique_field_ident.deref().to_case(Case::Snake); + let unique_field_type = type_name(module, unique_field_type_use); + writeln!( + out, + "_table.add_unique_constraint::<{unique_field_type}>({unique_field_name:?}, |row| &row.{unique_field_name});", + ); + } + }, + "}", + ); + if let Some(pk_field) = schema.pk() { let update_callback_id = table_name_pascalcase.clone() + "UpdateCallbackId"; @@ -217,9 +236,9 @@ impl<'ctx> __sdk::table::Table for {table_handle}<'ctx> {{ write!( out, " -pub struct {update_callback_id}(__sdk::callbacks::CallbackId); +pub struct {update_callback_id}(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for {table_handle}<'ctx> {{ +impl<'ctx> __sdk::TableWithPrimaryKey for {table_handle}<'ctx> {{ type UpdateCallbackId = {update_callback_id}; fn on_update( @@ -237,8 +256,8 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for {table_handle}<'ctx> {{ #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate<{row_type}>> {{ - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::<{pk_field_type}>( +) -> __anyhow::Result<__sdk::TableUpdate<{row_type}>> {{ + __sdk::TableUpdate::parse_table_update_with_primary_key::<{pk_field_type}>( raw_updates, |row: &{row_type}| &row.{pk_field_name}, ).context(\"Failed to parse table update for table \\\"{table_name}\\\"\") @@ -252,28 +271,24 @@ pub(super) fn parse_table_update( #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate<{row_type}>> {{ - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate<{row_type}>> {{ + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context(\"Failed to parse table update for table \\\"{table_name}\\\"\") }} " ); } - let constraints = schema.backcompat_column_constraints(); - - for field in schema.columns() { - if constraints[&ColList::from(field.col_pos)].has_unique() { - let (unique_field_ident, unique_field_type_use) = &product_def.elements[field.col_pos.idx()]; - let unique_field_name = unique_field_ident.deref().to_case(Case::Snake); - let unique_field_name_pascalcase = unique_field_name.to_case(Case::Pascal); + for (unique_field_ident, unique_field_type_use) in iter_unique_cols(&schema, product_def) { + let unique_field_name = unique_field_ident.deref().to_case(Case::Snake); + let unique_field_name_pascalcase = unique_field_name.to_case(Case::Pascal); - let unique_constraint = table_name_pascalcase.clone() + &unique_field_name_pascalcase + "Unique"; - let unique_field_type = type_name(module, unique_field_type_use); + let unique_constraint = table_name_pascalcase.clone() + &unique_field_name_pascalcase + "Unique"; + let unique_field_type = type_name(module, unique_field_type_use); - write!( - out, - " + write!( + out, + " /// Access to the `{unique_field_name}` unique index on the table `{table_name}`, /// which allows point queries on the field of the same name /// via the [`{unique_constraint}::find`] method. @@ -282,7 +297,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.{accessor_method}().{unique_field_name}().find(...)`. pub struct {unique_constraint}<'ctx> {{ - imp: __sdk::client_cache::UniqueConstraint<{row_type}, {unique_field_type}>, + imp: __sdk::UniqueConstraintHandle<{row_type}, {unique_field_type}>, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, }} @@ -290,7 +305,7 @@ pub(super) fn parse_table_update( /// Get a handle on the `{unique_field_name}` unique index on the table `{table_name}`. pub fn {unique_field_name}(&self) -> {unique_constraint}<'ctx> {{ {unique_constraint} {{ - imp: self.imp.get_unique_constraint::<{unique_field_type}>({unique_field_name:?}, |row| &row.{unique_field_name}), + imp: self.imp.get_unique_constraint::<{unique_field_type}>({unique_field_name:?}), phantom: std::marker::PhantomData, }} }} @@ -304,8 +319,7 @@ pub(super) fn parse_table_update( }} }} " - ); - } + ); } // TODO: expose non-unique indices. @@ -339,14 +353,31 @@ Requested namespace: {namespace}", let reducer_name = reducer.name.deref(); let func_name = reducer_function_name(reducer); - let set_reducer_flags_trait = format!("set_flags_for_{func_name}"); + let set_reducer_flags_trait = reducer_flags_trait_name(reducer); let args_type = reducer_args_type_name(&reducer.name); - - define_struct_for_product(module, out, &args_type, &reducer.params_for_generate.elements); + let enum_variant_name = reducer_variant_name(&reducer.name); + + // Define an "args struct" for the reducer. + // This is not user-facing (note the `pub(super)` visibility); + // it is an internal helper for serialization and deserialization. + // We actually want to ser/de instances of `enum Reducer`, but: + // - `Reducer` will have struct-like variants, which SATS ser/de does not support. + // - The WS format does not contain a BSATN-serialized `Reducer` instance; + // it holds the reducer name or ID separately from the argument bytes. + // We could work up some magic with `DeserializeSeed` + // and/or custom `Serializer` and `Deserializer` types + // to account for this, but it's much easier to just use an intermediate struct per reducer. + define_struct_for_product( + module, + out, + &args_type, + &reducer.params_for_generate.elements, + "pub(super)", + ); out.newline(); - let callback_id = args_type.clone() + "CallbackId"; + let callback_id = reducer_callback_id_name(&reducer.name); // The reducer arguments as `ident: ty, ident: ty, ident: ty,`, // like an argument list. @@ -359,10 +390,6 @@ Requested namespace: {namespace}", // The reducer argument names as `ident, ident, ident`, // for passing to function call and struct literal expressions. let mut arg_names_list = String::new(); - // The reducer argument names as `&args.ident, &args.ident, &args.ident`, - // for extracting from a structure named `args` by reference - // and passing to a function call. - let mut unboxed_arg_refs = String::new(); for (arg_ident, arg_ty) in &reducer.params_for_generate.elements[..] { arg_types_ref_list += "&"; write_type(module, &mut arg_types_ref_list, arg_ty).unwrap(); @@ -371,22 +398,50 @@ Requested namespace: {namespace}", let arg_name = arg_ident.deref().to_case(Case::Snake); arg_names_list += &arg_name; arg_names_list += ", "; - - unboxed_arg_refs += "&args."; - unboxed_arg_refs += &arg_name; - unboxed_arg_refs += ", "; } + write!(out, "impl From<{args_type}> for super::Reducer "); + out.delimited_block( + "{", + |out| { + write!(out, "fn from(args: {args_type}) -> Self "); + out.delimited_block( + "{", + |out| { + write!(out, "Self::{enum_variant_name}"); + if !reducer.params_for_generate.elements.is_empty() { + // We generate "struct variants" for reducers with arguments, + // but "unit variants" for reducers of no arguments. + // These use different constructor syntax. + out.delimited_block( + " {", + |out| { + for (arg_ident, _ty) in &reducer.params_for_generate.elements[..] { + let arg_name = arg_ident.deref().to_case(Case::Snake); + writeln!(out, "{arg_name}: args.{arg_name},"); + } + }, + "}", + ); + } + out.newline(); + }, + "}\n", + ); + }, + "}\n", + ); + // TODO: check for lifecycle reducers and do not generate the invoke method. writeln!( out, " -impl __sdk::spacetime_module::InModule for {args_type} {{ +impl __sdk::InModule for {args_type} {{ type Module = super::RemoteModule; }} -pub struct {callback_id}(__sdk::callbacks::CallbackId); +pub struct {callback_id}(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `{reducer_name}`. @@ -423,13 +478,24 @@ impl {func_name} for super::RemoteReducers {{ &self, mut callback: impl FnMut(&super::EventContext, {arg_types_ref_list}) + Send + 'static, ) -> {callback_id} {{ - {callback_id}(self.imp.on_reducer::<{args_type}>( + {callback_id}(self.imp.on_reducer( {reducer_name:?}, - Box::new(move |ctx: &super::EventContext, args: &{args_type}| callback(ctx, {unboxed_arg_refs})), + Box::new(move |ctx: &super::EventContext| {{ + let super::EventContext {{ + event: __sdk::Event::Reducer(__sdk::ReducerEvent {{ + reducer: super::Reducer::{enum_variant_name} {{ + {arg_names_list} + }}, + .. + }}), + .. + }} = ctx else {{ unreachable!() }}; + callback(ctx, {arg_names_list}) + }}), )) }} fn remove_on_{func_name}(&self, callback: {callback_id}) {{ - self.imp.remove_on_reducer::<{args_type}>({reducer_name:?}, callback.0) + self.imp.remove_on_reducer({reducer_name:?}, callback.0) }} }} @@ -497,6 +563,12 @@ Requested namespace: {namespace}", // Note that these do not change based on the module. print_const_db_context_types(out); + out.newline(); + + // Implement `SpacetimeModule` for `RemoteModule`. + // This includes a method for initializing the tables in the client cache. + print_impl_spacetime_module(module, out); + vec![("mod.rs".to_string(), (output.into_inner()))] } } @@ -552,12 +624,12 @@ pub fn type_name(module: &ModuleDef, ty: &AlgebraicTypeUse) -> String { const ALLOW_UNUSED: &str = "#![allow(unused)]"; const SPACETIMEDB_IMPORTS: &[&str] = &[ - "use spacetimedb_sdk::{", + "use spacetimedb_sdk::__codegen::{", "\tself as __sdk,", "\tanyhow::{self as __anyhow, Context as _},", - "\tlib as __lib,", - "\tsats as __sats,", - "\tws_messages as __ws,", + "\t__lib,", + "\t__sats,", + "\t__ws,", "};", ]; @@ -694,10 +766,11 @@ fn define_struct_for_product( out: &mut Indenter, name: &str, elements: &[(Identifier, AlgebraicTypeUse)], + vis: &str, ) { print_struct_derives(out); - write!(out, "pub struct {name} "); + write!(out, "{vis} struct {name} "); // TODO: if elements is empty, define a unit struct with no brace-delimited list of fields. write_struct_type_fields_in_braces( @@ -724,14 +797,22 @@ fn table_method_name(table_name: &Identifier) -> String { table_name.deref().to_case(Case::Snake) } +fn table_access_trait_name(table_name: &Identifier) -> String { + table_name.deref().to_case(Case::Pascal) + "TableAccess" +} + fn reducer_args_type_name(reducer_name: &Identifier) -> String { - reducer_name.deref().to_case(Case::Pascal) + reducer_name.deref().to_case(Case::Pascal) + "Args" } fn reducer_variant_name(reducer_name: &Identifier) -> String { reducer_name.deref().to_case(Case::Pascal) } +fn reducer_callback_id_name(reducer_name: &Identifier) -> String { + reducer_name.deref().to_case(Case::Pascal) + "CallbackId" +} + fn reducer_module_name(reducer_name: &Identifier) -> String { reducer_name.deref().to_case(Case::Snake) + "_reducer" } @@ -740,6 +821,10 @@ fn reducer_function_name(reducer: &ReducerDef) -> String { reducer.name.deref().to_case(Case::Snake) } +fn reducer_flags_trait_name(reducer: &ReducerDef) -> String { + format!("set_flags_for_{}", reducer_function_name(reducer)) +} + /// Iterate over all of the Rust `mod`s for types, reducers and tables in the `module`. fn iter_module_names(module: &ModuleDef) -> impl Iterator + '_ { itertools::chain!( @@ -756,10 +841,31 @@ fn print_module_decls(module: &ModuleDef, out: &mut Indenter) { } } -/// Print `pub use *` declarations for all the files that will be generated for `items`. +/// Print appropriate reexports for all the files that will be generated for `items`. fn print_module_reexports(module: &ModuleDef, out: &mut Indenter) { - for module_name in iter_module_names(module) { - writeln!(out, "pub use {module_name}::*;"); + for ty in module.types().sorted_by_key(|ty| &ty.name) { + let mod_name = type_module_name(&ty.name); + let type_name = collect_case(Case::Pascal, ty.name.name_segments()); + writeln!(out, "pub use {mod_name}::{type_name};") + } + for table in iter_tables(module) { + let mod_name = table_module_name(&table.name); + // TODO: More precise reexport: we want: + // - The trait name. + // - The insert, delete and possibly update callback ids. + // We do not want: + // - The table handle. + writeln!(out, "pub use {mod_name}::*;"); + } + for reducer in iter_reducers(module) { + let mod_name = reducer_module_name(&reducer.name); + let reducer_trait_name = reducer_function_name(reducer); + let flags_trait_name = reducer_flags_trait_name(reducer); + let callback_id_name = reducer_callback_id_name(&reducer.name); + writeln!( + out, + "pub use {mod_name}::{{{reducer_trait_name}, {flags_trait_name}, {callback_id_name}}};" + ); } } @@ -777,8 +883,26 @@ fn iter_tables(module: &ModuleDef) -> impl Iterator { module.tables().sorted_by_key(|table| &table.name) } +fn iter_unique_cols<'a>( + schema: &'a TableSchema, + product_def: &'a ProductTypeDef, +) -> impl Iterator + 'a { + let constraints = schema.backcompat_column_constraints(); + schema.columns().iter().filter_map(move |field| { + constraints[&ColList::from(field.col_pos)] + .has_unique() + .then(|| { + let res @ (_, ref ty) = &product_def.elements[field.col_pos.idx()]; + is_type_filterable(ty).then_some(res) + }) + .flatten() + }) +} + fn print_reducer_enum_defn(module: &ModuleDef, out: &mut Indenter) { - print_enum_derives(out); + // Don't derive ser/de on this enum; + // it's not a proper SATS enum and the derive will fail. + writeln!(out, "#[derive(Clone, PartialEq, Debug)]"); writeln!( out, " @@ -792,13 +916,15 @@ fn print_reducer_enum_defn(module: &ModuleDef, out: &mut Indenter) { "pub enum Reducer {", |out| { for reducer in iter_reducers(module) { - writeln!( - out, - "{}({}::{}),", - reducer_variant_name(&reducer.name), - reducer_module_name(&reducer.name), - reducer_args_type_name(&reducer.name), - ); + write!(out, "{} ", reducer_variant_name(&reducer.name)); + if !reducer.params_for_generate.elements.is_empty() { + // If the reducer has any arguments, generate a "struct variant," + // like `Foo { bar: Baz, }`. + // If it doesn't, generate a "unit variant" instead, + // like `Foo,`. + write_struct_type_fields_in_braces(module, out, &reducer.params_for_generate.elements, false); + } + writeln!(out, ","); } }, "}\n", @@ -807,14 +933,14 @@ fn print_reducer_enum_defn(module: &ModuleDef, out: &mut Indenter) { writeln!( out, " -impl __sdk::spacetime_module::InModule for Reducer {{ +impl __sdk::InModule for Reducer {{ type Module = RemoteModule; }} ", ); out.delimited_block( - "impl __sdk::spacetime_module::Reducer for Reducer {", + "impl __sdk::Reducer for Reducer {", |out| { out.delimited_block( "fn reducer_name(&self) -> &'static str {", @@ -823,27 +949,17 @@ impl __sdk::spacetime_module::InModule for Reducer {{ "match self {", |out| { for reducer in iter_reducers(module) { - writeln!( - out, - "Reducer::{}(_) => {:?},", - reducer_variant_name(&reducer.name), - reducer.name.deref(), - ); - } - }, - "}\n", - ); - }, - "}\n", - ); - out.delimited_block( - "fn reducer_args(&self) -> &dyn std::any::Any {", - |out| { - out.delimited_block( - "match self {", - |out| { - for reducer in iter_reducers(module) { - writeln!(out, "Reducer::{}(args) => args,", reducer_variant_name(&reducer.name)); + write!(out, "Reducer::{}", reducer_variant_name(&reducer.name)); + if !reducer.params_for_generate.elements.is_empty() { + // Because we're emitting unit variants when the payload is empty, + // we will emit different patterns for empty vs non-empty variants. + // This is not strictly required; + // Rust allows matching a struct-like pattern + // against a unit-like enum variant, + // but we prefer the clarity of not including the braces for unit variants. + write!(out, " {{ .. }}"); + } + writeln!(out, " => {:?},", reducer.name.deref()); } }, "}\n", @@ -859,29 +975,45 @@ impl __sdk::spacetime_module::InModule for Reducer {{ "impl TryFrom<__ws::ReducerCallInfo<__ws::BsatnFormat>> for Reducer {", |out| { writeln!(out, "type Error = __anyhow::Error;"); + // We define an "args struct" for each reducer in `generate_reducer`. + // This is not user-facing, and is not exported past the "root" `mod.rs`; + // it is an internal helper for serialization and deserialization. + // We actually want to ser/de instances of `enum Reducer`, but: + // + // - `Reducer` will have struct-like variants, which SATS ser/de does not support. + // - The WS format does not contain a BSATN-serialized `Reducer` instance; + // it holds the reducer name or ID separately from the argument bytes. + // We could work up some magic with `DeserializeSeed` + // and/or custom `Serializer` and `Deserializer` types + // to account for this, but it's much easier to just use an intermediate struct per reducer. + // + // As such, we deserialize from the `value.args` bytes into that "args struct," + // then convert it into a `Reducer` variant via `Into::into`, + // which we also implement in `generate_reducer`. out.delimited_block( "fn try_from(value: __ws::ReducerCallInfo<__ws::BsatnFormat>) -> __anyhow::Result {", - |out| { - out.delimited_block( - "match &value.reducer_name[..] {", - |out| { - for reducer in iter_reducers(module) { - writeln!( - out, - "{:?} => Ok(Reducer::{}(__sdk::spacetime_module::parse_reducer_args({:?}, &value.args)?)),", - reducer.name.deref(), - reducer_variant_name(&reducer.name), - reducer.name.deref(), - ); - } + |out| { + out.delimited_block( + "match &value.reducer_name[..] {", + |out| { + for reducer in iter_reducers(module) { writeln!( out, - "_ => Err(__anyhow::anyhow!(\"Unknown reducer {{:?}}\", value.reducer_name)),", + "{:?} => Ok(__sdk::parse_reducer_args::<{}::{}>({:?}, &value.args)?.into()),", + reducer.name.deref(), + reducer_module_name(&reducer.name), + reducer_args_type_name(&reducer.name), + reducer.name.deref(), ); - }, - "}\n", - ) - }, + } + writeln!( + out, + "_ => Err(__anyhow::anyhow!(\"Unknown reducer {{:?}}\", value.reducer_name)),", + ); + }, + "}\n", + ) + }, "}\n", ); }, @@ -899,7 +1031,7 @@ fn print_db_update_defn(module: &ModuleDef, out: &mut Indenter) { for table in iter_tables(module) { writeln!( out, - "{}: __sdk::spacetime_module::TableUpdate<{}>,", + "{}: __sdk::TableUpdate<{}>,", table_method_name(&table.name), type_ref_name(module, table.product_type_ref), ); @@ -944,17 +1076,17 @@ impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate { writeln!( out, " -impl __sdk::spacetime_module::InModule for DbUpdate {{ +impl __sdk::InModule for DbUpdate {{ type Module = RemoteModule; }} ", ); out.delimited_block( - "impl __sdk::spacetime_module::DbUpdate for DbUpdate {", + "impl __sdk::DbUpdate for DbUpdate {", |out| { out.delimited_block( - "fn apply_to_client_cache(&self, cache: &mut __sdk::client_cache::ClientCache) {", + "fn apply_to_client_cache(&self, cache: &mut __sdk::ClientCache) {", |out| { for table in iter_tables(module) { writeln!( @@ -970,7 +1102,7 @@ impl __sdk::spacetime_module::InModule for DbUpdate {{ ); out.delimited_block( - "fn invoke_row_callbacks(&self, event: &EventContext, callbacks: &mut __sdk::callbacks::DbCallbacks) {", + "fn invoke_row_callbacks(&self, event: &EventContext, callbacks: &mut __sdk::DbCallbacks) {", |out| { for table in iter_tables(module) { writeln!( @@ -989,6 +1121,37 @@ impl __sdk::spacetime_module::InModule for DbUpdate {{ ); } +fn print_impl_spacetime_module(module: &ModuleDef, out: &mut Indenter) { + out.delimited_block( + "impl __sdk::SpacetimeModule for RemoteModule {", + |out| { + writeln!( + out, + " +type DbConnection = DbConnection; +type EventContext = EventContext; +type Reducer = Reducer; +type DbView = RemoteTables; +type Reducers = RemoteReducers; +type SetReducerFlags = SetReducerFlags; +type DbUpdate = DbUpdate; +type SubscriptionHandle = SubscriptionHandle; +" + ); + out.delimited_block( + "fn register_tables(client_cache: &mut __sdk::ClientCache) {", + |out| { + for table in iter_tables(module) { + writeln!(out, "{}::register_table(client_cache);", table_module_name(&table.name)); + } + }, + "}\n", + ); + }, + "}\n", + ); +} + fn print_const_db_context_types(out: &mut Indenter) { writeln!( out, @@ -996,28 +1159,17 @@ fn print_const_db_context_types(out: &mut Indenter) { #[doc(hidden)] pub struct RemoteModule; -impl __sdk::spacetime_module::InModule for RemoteModule {{ +impl __sdk::InModule for RemoteModule {{ type Module = Self; }} -impl __sdk::spacetime_module::SpacetimeModule for RemoteModule {{ - type DbConnection = DbConnection; - type EventContext = EventContext; - type Reducer = Reducer; - type DbView = RemoteTables; - type Reducers = RemoteReducers; - type SetReducerFlags = SetReducerFlags; - type DbUpdate = DbUpdate; - type SubscriptionHandle = SubscriptionHandle; -}} - /// The `reducers` field of [`EventContext`] and [`DbConnection`], /// with methods provided by extension traits for each reducer defined by the module. pub struct RemoteReducers {{ - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, }} -impl __sdk::spacetime_module::InModule for RemoteReducers {{ +impl __sdk::InModule for RemoteReducers {{ type Module = RemoteModule; }} @@ -1028,20 +1180,20 @@ impl __sdk::spacetime_module::InModule for RemoteReducers {{ /// /// This type is currently unstable and may be removed without a major version bump. pub struct SetReducerFlags {{ - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, }} -impl __sdk::spacetime_module::InModule for SetReducerFlags {{ +impl __sdk::InModule for SetReducerFlags {{ type Module = RemoteModule; }} /// The `db` field of [`EventContext`] and [`DbConnection`], /// with methods provided by extension traits for each table defined by the module. pub struct RemoteTables {{ - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, }} -impl __sdk::spacetime_module::InModule for RemoteTables {{ +impl __sdk::InModule for RemoteTables {{ type Module = RemoteModule; }} @@ -1073,14 +1225,14 @@ pub struct DbConnection {{ /// This type is currently unstable and may be removed without a major version bump. pub set_reducer_flags: SetReducerFlags, - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, }} -impl __sdk::spacetime_module::InModule for DbConnection {{ +impl __sdk::InModule for DbConnection {{ type Module = RemoteModule; }} -impl __sdk::db_context::DbContext for DbConnection {{ +impl __sdk::DbContext for DbConnection {{ type DbView = RemoteTables; type Reducers = RemoteReducers; type SetReducerFlags = SetReducerFlags; @@ -1103,10 +1255,10 @@ impl __sdk::db_context::DbContext for DbConnection {{ self.imp.disconnect() }} - type SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder; + type SubscriptionBuilder = __sdk::SubscriptionBuilder; fn subscription_builder(&self) -> Self::SubscriptionBuilder {{ - __sdk::subscription::SubscriptionBuilder::new(&self.imp) + __sdk::SubscriptionBuilder::new(&self.imp) }} fn try_identity(&self) -> Option<__sdk::Identity> {{ @@ -1122,7 +1274,7 @@ impl DbConnection {{ /// /// See [`__sdk::DbConnectionBuilder`] for required and optional configuration for the new connection. pub fn builder() -> __sdk::DbConnectionBuilder {{ - __sdk::db_connection::DbConnectionBuilder::new() + __sdk::DbConnectionBuilder::new() }} /// If any WebSocket messages are waiting, process one of them. @@ -1188,8 +1340,8 @@ impl DbConnection {{ }} }} -impl __sdk::spacetime_module::DbConnection for DbConnection {{ - fn new(imp: __sdk::db_connection::DbContextImpl) -> Self {{ +impl __sdk::DbConnection for DbConnection {{ + fn new(imp: __sdk::DbContextImpl) -> Self {{ Self {{ db: RemoteTables {{ imp: imp.clone() }}, reducers: RemoteReducers {{ imp: imp.clone() }}, @@ -1212,15 +1364,15 @@ pub struct EventContext {{ /// This type is currently unstable and may be removed without a major version bump. pub set_reducer_flags: SetReducerFlags, /// The event which caused these callbacks to run. - pub event: __sdk::event::Event, - imp: __sdk::db_connection::DbContextImpl, + pub event: __sdk::Event, + imp: __sdk::DbContextImpl, }} -impl __sdk::spacetime_module::InModule for EventContext {{ +impl __sdk::InModule for EventContext {{ type Module = RemoteModule; }} -impl __sdk::db_context::DbContext for EventContext {{ +impl __sdk::DbContext for EventContext {{ type DbView = RemoteTables; type Reducers = RemoteReducers; type SetReducerFlags = SetReducerFlags; @@ -1239,14 +1391,14 @@ impl __sdk::db_context::DbContext for EventContext {{ self.imp.is_active() }} - fn disconnect(&self) -> spacetimedb_sdk::anyhow::Result<()> {{ + fn disconnect(&self) -> __anyhow::Result<()> {{ self.imp.disconnect() }} - type SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder; + type SubscriptionBuilder = __sdk::SubscriptionBuilder; fn subscription_builder(&self) -> Self::SubscriptionBuilder {{ - __sdk::subscription::SubscriptionBuilder::new(&self.imp) + __sdk::SubscriptionBuilder::new(&self.imp) }} fn try_identity(&self) -> Option<__sdk::Identity> {{ @@ -1257,11 +1409,11 @@ impl __sdk::db_context::DbContext for EventContext {{ }} }} -impl __sdk::spacetime_module::EventContext for EventContext {{ - fn event(&self) -> &__sdk::event::Event {{ +impl __sdk::EventContext for EventContext {{ + fn event(&self) -> &__sdk::Event {{ &self.event }} - fn new(imp: __sdk::db_connection::DbContextImpl, event: __sdk::event::Event) -> Self {{ + fn new(imp: __sdk::DbContextImpl, event: __sdk::Event) -> Self {{ Self {{ db: RemoteTables {{ imp: imp.clone() }}, reducers: RemoteReducers {{ imp: imp.clone() }}, @@ -1275,15 +1427,15 @@ impl __sdk::spacetime_module::EventContext for EventContext {{ /// A handle on a subscribed query. // TODO: Document this better after implementing the new subscription API. pub struct SubscriptionHandle {{ - imp: __sdk::subscription::SubscriptionHandleImpl, + imp: __sdk::SubscriptionHandleImpl, }} -impl __sdk::spacetime_module::InModule for SubscriptionHandle {{ +impl __sdk::InModule for SubscriptionHandle {{ type Module = RemoteModule; }} -impl __sdk::spacetime_module::SubscriptionHandle for SubscriptionHandle {{ - fn new(imp: __sdk::subscription::SubscriptionHandleImpl) -> Self {{ +impl __sdk::SubscriptionHandle for SubscriptionHandle {{ + fn new(imp: __sdk::SubscriptionHandleImpl) -> Self {{ Self {{ imp }} }} }} @@ -1297,13 +1449,13 @@ pub trait RemoteDbContext: __sdk::DbContext< DbView = RemoteTables, Reducers = RemoteReducers, SetReducerFlags = SetReducerFlags, - SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder, + SubscriptionBuilder = __sdk::SubscriptionBuilder, > {{}} impl, + SubscriptionBuilder = __sdk::SubscriptionBuilder, >> RemoteDbContext for Ctx {{}} ", ); diff --git a/crates/cli/src/subcommands/generate/util.rs b/crates/cli/src/subcommands/generate/util.rs index e21ffc3e12f..22a1fb5709e 100644 --- a/crates/cli/src/subcommands/generate/util.rs +++ b/crates/cli/src/subcommands/generate/util.rs @@ -8,7 +8,11 @@ use std::{ use convert_case::{Case, Casing}; use itertools::Itertools; use spacetimedb_lib::sats::AlgebraicTypeRef; -use spacetimedb_schema::{def::ModuleDef, identifier::Identifier}; +use spacetimedb_schema::{ + def::ModuleDef, + identifier::Identifier, + type_for_generate::{AlgebraicTypeUse, PrimitiveType}, +}; use super::code_indenter::Indenter; @@ -57,3 +61,11 @@ pub(super) fn type_ref_name(module: &ModuleDef, typeref: AlgebraicTypeRef) -> St let (name, _def) = module.type_def_from_ref(typeref).unwrap(); collect_case(Case::Pascal, name.name_segments()) } + +pub(super) fn is_type_filterable(ty: &AlgebraicTypeUse) -> bool { + match ty { + AlgebraicTypeUse::Primitive(prim) => !matches!(prim, PrimitiveType::F32 | PrimitiveType::F64), + AlgebraicTypeUse::String | AlgebraicTypeUse::Identity | AlgebraicTypeUse::Address => true, + _ => false, + } +} diff --git a/crates/cli/src/util.rs b/crates/cli/src/util.rs index 69889f29325..44506597ff5 100644 --- a/crates/cli/src/util.rs +++ b/crates/cli/src/util.rs @@ -5,7 +5,7 @@ use base64::{ }; use reqwest::RequestBuilder; use serde::Deserialize; -use spacetimedb::auth::identity::SpacetimeIdentityClaims2; +use spacetimedb::auth::identity::{IncomingClaims, SpacetimeIdentityClaims2}; use spacetimedb_client_api_messages::name::{DnsLookupResponse, RegisterTldResult, ReverseDNSResponse}; use spacetimedb_data_structures::map::HashMap; use spacetimedb_lib::{AlgebraicType, Identity}; @@ -280,7 +280,8 @@ pub fn decode_identity(config: &Config) -> anyhow::Result { let decoded_bytes = BASE_64_STD_NO_PAD.decode(token_parts[1])?; let decoded_string = String::from_utf8(decoded_bytes)?; - let claims_data: SpacetimeIdentityClaims2 = serde_json::from_str(decoded_string.as_str())?; + let claims_data: IncomingClaims = serde_json::from_str(decoded_string.as_str())?; + let claims_data: SpacetimeIdentityClaims2 = claims_data.try_into()?; Ok(claims_data.identity.to_string()) } diff --git a/crates/cli/tests/snapshots/codegen__codegen_csharp.snap b/crates/cli/tests/snapshots/codegen__codegen_csharp.snap index 686b9144c81..dfc63bedf25 100644 --- a/crates/cli/tests/snapshots/codegen__codegen_csharp.snap +++ b/crates/cli/tests/snapshots/codegen__codegen_csharp.snap @@ -1,47 +1,8 @@ --- source: crates/cli/tests/codegen.rs expression: outfiles +snapshot_kind: text --- -"AddPlayerReducer.cs" = ''' -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -// - -#nullable enable - -using System; - -namespace SpacetimeDB -{ - [SpacetimeDB.Type] - public partial class AddPlayer : IReducerArgs - { - string IReducerArgs.ReducerName => "add_player"; - - public string Name = ""; - } -} -''' -"AddPrivateReducer.cs" = ''' -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -// - -#nullable enable - -using System; - -namespace SpacetimeDB -{ - [SpacetimeDB.Type] - public partial class AddPrivate : IReducerArgs - { - string IReducerArgs.ReducerName => "add_private"; - - public string Name = ""; - } -} -''' "Baz.cs" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. @@ -62,9 +23,7 @@ namespace SpacetimeDB [DataMember(Name = "field")] public string Field; - public Baz( - string Field - ) + public Baz(string Field) { this.Field = Field; } @@ -77,46 +36,6 @@ namespace SpacetimeDB } } ''' -"DeletePlayerReducer.cs" = ''' -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -// - -#nullable enable - -using System; - -namespace SpacetimeDB -{ - [SpacetimeDB.Type] - public partial class DeletePlayer : IReducerArgs - { - string IReducerArgs.ReducerName => "delete_player"; - - public ulong Id; - } -} -''' -"DeletePlayersByNameReducer.cs" = ''' -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -// - -#nullable enable - -using System; - -namespace SpacetimeDB -{ - [SpacetimeDB.Type] - public partial class DeletePlayersByName : IReducerArgs - { - string IReducerArgs.ReducerName => "delete_players_by_name"; - - public string Name = ""; - } -} -''' "Foobar.cs" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. @@ -322,9 +241,7 @@ namespace SpacetimeDB [DataMember(Name = "name")] public string Name; - public Private( - string Name - ) + public Private(string Name) { this.Name = Name; } @@ -337,24 +254,6 @@ namespace SpacetimeDB } } ''' -"QueryPrivateReducer.cs" = ''' -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -// - -#nullable enable - -using System; - -namespace SpacetimeDB -{ - [SpacetimeDB.Type] - public partial class QueryPrivate : IReducerArgs - { - string IReducerArgs.ReducerName => "query_private"; - } -} -''' "RepeatingTestArg.cs" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. @@ -372,22 +271,22 @@ namespace SpacetimeDB [DataContract] public partial class RepeatingTestArg : IDatabaseRow { - [DataMember(Name = "prev_time")] - public ulong PrevTime; [DataMember(Name = "scheduled_id")] public ulong ScheduledId; [DataMember(Name = "scheduled_at")] public SpacetimeDB.ScheduleAt ScheduledAt; + [DataMember(Name = "prev_time")] + public ulong PrevTime; public RepeatingTestArg( - ulong PrevTime, ulong ScheduledId, - SpacetimeDB.ScheduleAt ScheduledAt + SpacetimeDB.ScheduleAt ScheduledAt, + ulong PrevTime ) { - this.PrevTime = PrevTime; this.ScheduledId = ScheduledId; this.ScheduledAt = ScheduledAt; + this.PrevTime = PrevTime; } public RepeatingTestArg() @@ -398,26 +297,6 @@ namespace SpacetimeDB } } ''' -"RepeatingTestReducer.cs" = ''' -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -// - -#nullable enable - -using System; - -namespace SpacetimeDB -{ - [SpacetimeDB.Type] - public partial class RepeatingTest : IReducerArgs - { - string IReducerArgs.ReducerName => "repeating_test"; - - public SpacetimeDB.RepeatingTestArg Arg = new(); - } -} -''' "TestA.cs" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. @@ -481,9 +360,7 @@ namespace SpacetimeDB [DataMember(Name = "foo")] public string Foo; - public TestB( - string Foo - ) + public TestB(string Foo) { this.Foo = Foo; } @@ -496,24 +373,6 @@ namespace SpacetimeDB } } ''' -"TestBtreeIndexArgsReducer.cs" = ''' -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -// - -#nullable enable - -using System; - -namespace SpacetimeDB -{ - [SpacetimeDB.Type] - public partial class TestBtreeIndexArgs : IReducerArgs - { - string IReducerArgs.ReducerName => "test_btree_index_args"; - } -} -''' "TestD.cs" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. @@ -534,9 +393,7 @@ namespace SpacetimeDB [DataMember(Name = "test_c")] public SpacetimeDB.Namespace.Types.TestC? TestC; - public TestD( - SpacetimeDB.Namespace.Types.TestC? TestC - ) + public TestD(SpacetimeDB.Namespace.Types.TestC? TestC) { this.TestC = TestC; } @@ -607,9 +464,7 @@ namespace SpacetimeDB [DataMember(Name = "field")] public SpacetimeDB.Foobar Field; - public TestFoobar( - SpacetimeDB.Foobar Field - ) + public TestFoobar(SpacetimeDB.Foobar Field) { this.Field = Field; } @@ -622,29 +477,6 @@ namespace SpacetimeDB } } ''' -"TestReducer.cs" = ''' -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -// - -#nullable enable - -using System; - -namespace SpacetimeDB -{ - [SpacetimeDB.Type] - public partial class Test : IReducerArgs - { - string IReducerArgs.ReducerName => "test"; - - public SpacetimeDB.TestA Arg = new(); - public SpacetimeDB.TestB Arg2 = new(); - public SpacetimeDB.Namespace.Types.TestC Arg3; - public SpacetimeDB.Namespace.TestF Arg4 = null!; - } -} -''' "_Globals/SpacetimeDBClient.cs" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. @@ -655,6 +487,7 @@ namespace SpacetimeDB using System; using SpacetimeDB.ClientApi; using System.Collections.Generic; +using System.Runtime.Serialization; namespace SpacetimeDB { @@ -887,10 +720,10 @@ namespace SpacetimeDB public void AddPlayer(string name) { - conn.InternalCallReducer(new AddPlayer { Name = name }, this.SetCallReducerFlags.AddPlayerFlags); + conn.InternalCallReducer(new Reducer.AddPlayer(name), this.SetCallReducerFlags.AddPlayerFlags); } - public bool InvokeAddPlayer(EventContext ctx, AddPlayer args) + public bool InvokeAddPlayer(EventContext ctx, Reducer.AddPlayer args) { if (OnAddPlayer == null) return false; OnAddPlayer( @@ -904,10 +737,10 @@ namespace SpacetimeDB public void AddPrivate(string name) { - conn.InternalCallReducer(new AddPrivate { Name = name }, this.SetCallReducerFlags.AddPrivateFlags); + conn.InternalCallReducer(new Reducer.AddPrivate(name), this.SetCallReducerFlags.AddPrivateFlags); } - public bool InvokeAddPrivate(EventContext ctx, AddPrivate args) + public bool InvokeAddPrivate(EventContext ctx, Reducer.AddPrivate args) { if (OnAddPrivate == null) return false; OnAddPrivate( @@ -921,10 +754,10 @@ namespace SpacetimeDB public void DeletePlayer(ulong id) { - conn.InternalCallReducer(new DeletePlayer { Id = id }, this.SetCallReducerFlags.DeletePlayerFlags); + conn.InternalCallReducer(new Reducer.DeletePlayer(id), this.SetCallReducerFlags.DeletePlayerFlags); } - public bool InvokeDeletePlayer(EventContext ctx, DeletePlayer args) + public bool InvokeDeletePlayer(EventContext ctx, Reducer.DeletePlayer args) { if (OnDeletePlayer == null) return false; OnDeletePlayer( @@ -938,10 +771,10 @@ namespace SpacetimeDB public void DeletePlayersByName(string name) { - conn.InternalCallReducer(new DeletePlayersByName { Name = name }, this.SetCallReducerFlags.DeletePlayersByNameFlags); + conn.InternalCallReducer(new Reducer.DeletePlayersByName(name), this.SetCallReducerFlags.DeletePlayersByNameFlags); } - public bool InvokeDeletePlayersByName(EventContext ctx, DeletePlayersByName args) + public bool InvokeDeletePlayersByName(EventContext ctx, Reducer.DeletePlayersByName args) { if (OnDeletePlayersByName == null) return false; OnDeletePlayersByName( @@ -955,10 +788,10 @@ namespace SpacetimeDB public void QueryPrivate() { - conn.InternalCallReducer(new QueryPrivate { }, this.SetCallReducerFlags.QueryPrivateFlags); + conn.InternalCallReducer(new Reducer.QueryPrivate(), this.SetCallReducerFlags.QueryPrivateFlags); } - public bool InvokeQueryPrivate(EventContext ctx, QueryPrivate args) + public bool InvokeQueryPrivate(EventContext ctx, Reducer.QueryPrivate args) { if (OnQueryPrivate == null) return false; OnQueryPrivate( @@ -971,10 +804,10 @@ namespace SpacetimeDB public void RepeatingTest(SpacetimeDB.RepeatingTestArg arg) { - conn.InternalCallReducer(new RepeatingTest { Arg = arg }, this.SetCallReducerFlags.RepeatingTestFlags); + conn.InternalCallReducer(new Reducer.RepeatingTest(arg), this.SetCallReducerFlags.RepeatingTestFlags); } - public bool InvokeRepeatingTest(EventContext ctx, RepeatingTest args) + public bool InvokeRepeatingTest(EventContext ctx, Reducer.RepeatingTest args) { if (OnRepeatingTest == null) return false; OnRepeatingTest( @@ -988,10 +821,10 @@ namespace SpacetimeDB public void Test(SpacetimeDB.TestA arg, SpacetimeDB.TestB arg2, SpacetimeDB.Namespace.Types.TestC arg3, SpacetimeDB.Namespace.TestF arg4) { - conn.InternalCallReducer(new Test { Arg = arg, Arg2 = arg2, Arg3 = arg3, Arg4 = arg4 }, this.SetCallReducerFlags.TestFlags); + conn.InternalCallReducer(new Reducer.Test(arg, arg2, arg3, arg4), this.SetCallReducerFlags.TestFlags); } - public bool InvokeTest(EventContext ctx, Test args) + public bool InvokeTest(EventContext ctx, Reducer.Test args) { if (OnTest == null) return false; OnTest( @@ -1008,10 +841,10 @@ namespace SpacetimeDB public void TestBtreeIndexArgs() { - conn.InternalCallReducer(new TestBtreeIndexArgs { }, this.SetCallReducerFlags.TestBtreeIndexArgsFlags); + conn.InternalCallReducer(new Reducer.TestBtreeIndexArgs(), this.SetCallReducerFlags.TestBtreeIndexArgsFlags); } - public bool InvokeTestBtreeIndexArgs(EventContext ctx, TestBtreeIndexArgs args) + public bool InvokeTestBtreeIndexArgs(EventContext ctx, Reducer.TestBtreeIndexArgs args) { if (OnTestBtreeIndexArgs == null) return false; OnTestBtreeIndexArgs( @@ -1056,20 +889,164 @@ namespace SpacetimeDB } } - [Type] - public partial record Reducer : TaggedEnum<( - AddPlayer AddPlayer, - AddPrivate AddPrivate, - DeletePlayer DeletePlayer, - DeletePlayersByName DeletePlayersByName, - QueryPrivate QueryPrivate, - RepeatingTest RepeatingTest, - Test Test, - TestBtreeIndexArgs TestBtreeIndexArgs, - Unit StdbNone, - Unit StdbIdentityConnected, - Unit StdbIdentityDisconnected - )>; + public abstract partial class Reducer + { + private Reducer() { } + + [SpacetimeDB.Type] + [DataContract] + public partial class AddPlayer : Reducer, IReducerArgs + { + [DataMember(Name = "name")] + public string Name; + + public AddPlayer(string Name) + { + this.Name = Name; + } + + public AddPlayer() + { + this.Name = ""; + } + + string IReducerArgs.ReducerName => "add_player"; + } + + [SpacetimeDB.Type] + [DataContract] + public partial class AddPrivate : Reducer, IReducerArgs + { + [DataMember(Name = "name")] + public string Name; + + public AddPrivate(string Name) + { + this.Name = Name; + } + + public AddPrivate() + { + this.Name = ""; + } + + string IReducerArgs.ReducerName => "add_private"; + } + + [SpacetimeDB.Type] + [DataContract] + public partial class DeletePlayer : Reducer, IReducerArgs + { + [DataMember(Name = "id")] + public ulong Id; + + public DeletePlayer(ulong Id) + { + this.Id = Id; + } + + public DeletePlayer() + { + } + + string IReducerArgs.ReducerName => "delete_player"; + } + + [SpacetimeDB.Type] + [DataContract] + public partial class DeletePlayersByName : Reducer, IReducerArgs + { + [DataMember(Name = "name")] + public string Name; + + public DeletePlayersByName(string Name) + { + this.Name = Name; + } + + public DeletePlayersByName() + { + this.Name = ""; + } + + string IReducerArgs.ReducerName => "delete_players_by_name"; + } + + [SpacetimeDB.Type] + [DataContract] + public partial class QueryPrivate : Reducer, IReducerArgs + { + string IReducerArgs.ReducerName => "query_private"; + } + + [SpacetimeDB.Type] + [DataContract] + public partial class RepeatingTest : Reducer, IReducerArgs + { + [DataMember(Name = "arg")] + public SpacetimeDB.RepeatingTestArg Arg; + + public RepeatingTest(SpacetimeDB.RepeatingTestArg Arg) + { + this.Arg = Arg; + } + + public RepeatingTest() + { + this.Arg = new(); + } + + string IReducerArgs.ReducerName => "repeating_test"; + } + + [SpacetimeDB.Type] + [DataContract] + public partial class Test : Reducer, IReducerArgs + { + [DataMember(Name = "arg")] + public SpacetimeDB.TestA Arg; + [DataMember(Name = "arg2")] + public SpacetimeDB.TestB Arg2; + [DataMember(Name = "arg3")] + public SpacetimeDB.Namespace.Types.TestC Arg3; + [DataMember(Name = "arg4")] + public SpacetimeDB.Namespace.TestF Arg4; + + public Test( + SpacetimeDB.TestA Arg, + SpacetimeDB.TestB Arg2, + SpacetimeDB.Namespace.Types.TestC Arg3, + SpacetimeDB.Namespace.TestF Arg4 + ) + { + this.Arg = Arg; + this.Arg2 = Arg2; + this.Arg3 = Arg3; + this.Arg4 = Arg4; + } + + public Test() + { + this.Arg = new(); + this.Arg2 = new(); + this.Arg4 = null!; + } + + string IReducerArgs.ReducerName => "test"; + } + + [SpacetimeDB.Type] + [DataContract] + public partial class TestBtreeIndexArgs : Reducer, IReducerArgs + { + string IReducerArgs.ReducerName => "test_btree_index_args"; + } + + public class StdbNone : Reducer {} + public class StdbIdentityConnected : Reducer {} + public class StdbIdentityDisconnected : Reducer {} + } + public class DbConnection : DbConnectionBase { public readonly RemoteTables Db = new(); @@ -1096,18 +1073,18 @@ namespace SpacetimeDB { var encodedArgs = update.ReducerCall.Args; return update.ReducerCall.ReducerName switch { - "add_player" => new Reducer.AddPlayer(BSATNHelpers.Decode(encodedArgs)), - "add_private" => new Reducer.AddPrivate(BSATNHelpers.Decode(encodedArgs)), - "delete_player" => new Reducer.DeletePlayer(BSATNHelpers.Decode(encodedArgs)), - "delete_players_by_name" => new Reducer.DeletePlayersByName(BSATNHelpers.Decode(encodedArgs)), - "query_private" => new Reducer.QueryPrivate(BSATNHelpers.Decode(encodedArgs)), - "repeating_test" => new Reducer.RepeatingTest(BSATNHelpers.Decode(encodedArgs)), - "test" => new Reducer.Test(BSATNHelpers.Decode(encodedArgs)), - "test_btree_index_args" => new Reducer.TestBtreeIndexArgs(BSATNHelpers.Decode(encodedArgs)), - "" => new Reducer.StdbNone(default), - "__identity_connected__" => new Reducer.StdbIdentityConnected(default), - "__identity_disconnected__" => new Reducer.StdbIdentityDisconnected(default), - "" => new Reducer.StdbNone(default), + "add_player" => BSATNHelpers.Decode(encodedArgs), + "add_private" => BSATNHelpers.Decode(encodedArgs), + "delete_player" => BSATNHelpers.Decode(encodedArgs), + "delete_players_by_name" => BSATNHelpers.Decode(encodedArgs), + "query_private" => BSATNHelpers.Decode(encodedArgs), + "repeating_test" => BSATNHelpers.Decode(encodedArgs), + "test" => BSATNHelpers.Decode(encodedArgs), + "test_btree_index_args" => BSATNHelpers.Decode(encodedArgs), + "" => new Reducer.StdbNone(), + "__identity_connected__" => new Reducer.StdbIdentityConnected(), + "__identity_disconnected__" => new Reducer.StdbIdentityDisconnected(), + "" => new Reducer.StdbNone(), var reducer => throw new ArgumentOutOfRangeException("Reducer", $"Unknown reducer {reducer}") }; } @@ -1119,14 +1096,14 @@ namespace SpacetimeDB { var eventContext = (EventContext)context; return reducer switch { - Reducer.AddPlayer(var args) => Reducers.InvokeAddPlayer(eventContext, args), - Reducer.AddPrivate(var args) => Reducers.InvokeAddPrivate(eventContext, args), - Reducer.DeletePlayer(var args) => Reducers.InvokeDeletePlayer(eventContext, args), - Reducer.DeletePlayersByName(var args) => Reducers.InvokeDeletePlayersByName(eventContext, args), - Reducer.QueryPrivate(var args) => Reducers.InvokeQueryPrivate(eventContext, args), - Reducer.RepeatingTest(var args) => Reducers.InvokeRepeatingTest(eventContext, args), - Reducer.Test(var args) => Reducers.InvokeTest(eventContext, args), - Reducer.TestBtreeIndexArgs(var args) => Reducers.InvokeTestBtreeIndexArgs(eventContext, args), + Reducer.AddPlayer args => Reducers.InvokeAddPlayer(eventContext, args), + Reducer.AddPrivate args => Reducers.InvokeAddPrivate(eventContext, args), + Reducer.DeletePlayer args => Reducers.InvokeDeletePlayer(eventContext, args), + Reducer.DeletePlayersByName args => Reducers.InvokeDeletePlayersByName(eventContext, args), + Reducer.QueryPrivate args => Reducers.InvokeQueryPrivate(eventContext, args), + Reducer.RepeatingTest args => Reducers.InvokeRepeatingTest(eventContext, args), + Reducer.Test args => Reducers.InvokeTest(eventContext, args), + Reducer.TestBtreeIndexArgs args => Reducers.InvokeTestBtreeIndexArgs(eventContext, args), Reducer.StdbNone or Reducer.StdbIdentityConnected or Reducer.StdbIdentityDisconnected => true, diff --git a/crates/cli/tests/snapshots/codegen__codegen_rust.snap b/crates/cli/tests/snapshots/codegen__codegen_rust.snap index 213ea25df70..45ccd008173 100644 --- a/crates/cli/tests/snapshots/codegen__codegen_rust.snap +++ b/crates/cli/tests/snapshots/codegen__codegen_rust.snap @@ -6,27 +6,34 @@ expression: outfiles // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct AddPlayer { +pub(super) struct AddPlayerArgs { pub name: String, } +impl From for super::Reducer { + fn from(args: AddPlayerArgs) -> Self { + Self::AddPlayer { + name: args.name, +} +} +} -impl __sdk::spacetime_module::InModule for AddPlayer { +impl __sdk::InModule for AddPlayerArgs { type Module = super::RemoteModule; } -pub struct AddPlayerCallbackId(__sdk::callbacks::CallbackId); +pub struct AddPlayerCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `add_player`. @@ -59,19 +66,30 @@ pub trait add_player { impl add_player for super::RemoteReducers { fn add_player(&self, name: String, ) -> __anyhow::Result<()> { - self.imp.call_reducer("add_player", AddPlayer { name, }) + self.imp.call_reducer("add_player", AddPlayerArgs { name, }) } fn on_add_player( &self, mut callback: impl FnMut(&super::EventContext, &String, ) + Send + 'static, ) -> AddPlayerCallbackId { - AddPlayerCallbackId(self.imp.on_reducer::( + AddPlayerCallbackId(self.imp.on_reducer( "add_player", - Box::new(move |ctx: &super::EventContext, args: &AddPlayer| callback(ctx, &args.name, )), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::AddPlayer { + name, + }, + .. + }), + .. + } = ctx else { unreachable!() }; + callback(ctx, name, ) + }), )) } fn remove_on_add_player(&self, callback: AddPlayerCallbackId) { - self.imp.remove_on_reducer::("add_player", callback.0) + self.imp.remove_on_reducer("add_player", callback.0) } } @@ -100,27 +118,34 @@ impl set_flags_for_add_player for super::SetReducerFlags { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct AddPrivate { +pub(super) struct AddPrivateArgs { pub name: String, } +impl From for super::Reducer { + fn from(args: AddPrivateArgs) -> Self { + Self::AddPrivate { + name: args.name, +} +} +} -impl __sdk::spacetime_module::InModule for AddPrivate { +impl __sdk::InModule for AddPrivateArgs { type Module = super::RemoteModule; } -pub struct AddPrivateCallbackId(__sdk::callbacks::CallbackId); +pub struct AddPrivateCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `add_private`. @@ -153,19 +178,30 @@ pub trait add_private { impl add_private for super::RemoteReducers { fn add_private(&self, name: String, ) -> __anyhow::Result<()> { - self.imp.call_reducer("add_private", AddPrivate { name, }) + self.imp.call_reducer("add_private", AddPrivateArgs { name, }) } fn on_add_private( &self, mut callback: impl FnMut(&super::EventContext, &String, ) + Send + 'static, ) -> AddPrivateCallbackId { - AddPrivateCallbackId(self.imp.on_reducer::( + AddPrivateCallbackId(self.imp.on_reducer( "add_private", - Box::new(move |ctx: &super::EventContext, args: &AddPrivate| callback(ctx, &args.name, )), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::AddPrivate { + name, + }, + .. + }), + .. + } = ctx else { unreachable!() }; + callback(ctx, name, ) + }), )) } fn remove_on_add_private(&self, callback: AddPrivateCallbackId) { - self.imp.remove_on_reducer::("add_private", callback.0) + self.imp.remove_on_reducer("add_private", callback.0) } } @@ -194,12 +230,12 @@ impl set_flags_for_add_private for super::SetReducerFlags { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; @@ -210,7 +246,7 @@ pub struct Baz { } -impl __sdk::spacetime_module::InModule for Baz { +impl __sdk::InModule for Baz { type Module = super::RemoteModule; } @@ -219,27 +255,34 @@ impl __sdk::spacetime_module::InModule for Baz { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePlayer { +pub(super) struct DeletePlayerArgs { pub id: u64, } +impl From for super::Reducer { + fn from(args: DeletePlayerArgs) -> Self { + Self::DeletePlayer { + id: args.id, +} +} +} -impl __sdk::spacetime_module::InModule for DeletePlayer { +impl __sdk::InModule for DeletePlayerArgs { type Module = super::RemoteModule; } -pub struct DeletePlayerCallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePlayerCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_player`. @@ -272,19 +315,30 @@ pub trait delete_player { impl delete_player for super::RemoteReducers { fn delete_player(&self, id: u64, ) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_player", DeletePlayer { id, }) + self.imp.call_reducer("delete_player", DeletePlayerArgs { id, }) } fn on_delete_player( &self, mut callback: impl FnMut(&super::EventContext, &u64, ) + Send + 'static, ) -> DeletePlayerCallbackId { - DeletePlayerCallbackId(self.imp.on_reducer::( + DeletePlayerCallbackId(self.imp.on_reducer( "delete_player", - Box::new(move |ctx: &super::EventContext, args: &DeletePlayer| callback(ctx, &args.id, )), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePlayer { + id, + }, + .. + }), + .. + } = ctx else { unreachable!() }; + callback(ctx, id, ) + }), )) } fn remove_on_delete_player(&self, callback: DeletePlayerCallbackId) { - self.imp.remove_on_reducer::("delete_player", callback.0) + self.imp.remove_on_reducer("delete_player", callback.0) } } @@ -313,27 +367,34 @@ impl set_flags_for_delete_player for super::SetReducerFlags { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePlayersByName { +pub(super) struct DeletePlayersByNameArgs { pub name: String, } +impl From for super::Reducer { + fn from(args: DeletePlayersByNameArgs) -> Self { + Self::DeletePlayersByName { + name: args.name, +} +} +} -impl __sdk::spacetime_module::InModule for DeletePlayersByName { +impl __sdk::InModule for DeletePlayersByNameArgs { type Module = super::RemoteModule; } -pub struct DeletePlayersByNameCallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePlayersByNameCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_players_by_name`. @@ -366,19 +427,30 @@ pub trait delete_players_by_name { impl delete_players_by_name for super::RemoteReducers { fn delete_players_by_name(&self, name: String, ) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_players_by_name", DeletePlayersByName { name, }) + self.imp.call_reducer("delete_players_by_name", DeletePlayersByNameArgs { name, }) } fn on_delete_players_by_name( &self, mut callback: impl FnMut(&super::EventContext, &String, ) + Send + 'static, ) -> DeletePlayersByNameCallbackId { - DeletePlayersByNameCallbackId(self.imp.on_reducer::( + DeletePlayersByNameCallbackId(self.imp.on_reducer( "delete_players_by_name", - Box::new(move |ctx: &super::EventContext, args: &DeletePlayersByName| callback(ctx, &args.name, )), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePlayersByName { + name, + }, + .. + }), + .. + } = ctx else { unreachable!() }; + callback(ctx, name, ) + }), )) } fn remove_on_delete_players_by_name(&self, callback: DeletePlayersByNameCallbackId) { - self.imp.remove_on_reducer::("delete_players_by_name", callback.0) + self.imp.remove_on_reducer("delete_players_by_name", callback.0) } } @@ -407,12 +479,12 @@ impl set_flags_for_delete_players_by_name for super::SetReducerFlags { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; use super::baz_type::Baz; @@ -430,7 +502,7 @@ pub enum Foobar { -impl __sdk::spacetime_module::InModule for Foobar { +impl __sdk::InModule for Foobar { type Module = super::RemoteModule; } @@ -439,12 +511,12 @@ impl __sdk::spacetime_module::InModule for Foobar { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; use super::has_special_stuff_type::HasSpecialStuff; @@ -457,7 +529,7 @@ use super::has_special_stuff_type::HasSpecialStuff; /// but to directly chain method calls, /// like `ctx.db.has_special_stuff().on_insert(...)`. pub struct HasSpecialStuffTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -480,10 +552,10 @@ impl HasSpecialStuffTableAccess for super::RemoteTables { } } -pub struct HasSpecialStuffInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct HasSpecialStuffDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct HasSpecialStuffInsertCallbackId(__sdk::CallbackId); +pub struct HasSpecialStuffDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for HasSpecialStuffTableHandle<'ctx> { +impl<'ctx> __sdk::Table for HasSpecialStuffTableHandle<'ctx> { type Row = HasSpecialStuff; type EventContext = super::EventContext; @@ -517,11 +589,16 @@ impl<'ctx> __sdk::table::Table for HasSpecialStuffTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + + let _table = client_cache.get_or_make_table::("has_special_stuff"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"has_special_stuff\"") } ''' @@ -529,12 +606,12 @@ pub(super) fn parse_table_update( // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; @@ -546,7 +623,7 @@ pub struct HasSpecialStuff { } -impl __sdk::spacetime_module::InModule for HasSpecialStuff { +impl __sdk::InModule for HasSpecialStuff { type Module = super::RemoteModule; } @@ -555,26 +632,31 @@ impl __sdk::spacetime_module::InModule for HasSpecialStuff { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct IdentityConnected { +pub(super) struct IdentityConnectedArgs { } +impl From for super::Reducer { + fn from(args: IdentityConnectedArgs) -> Self { + Self::IdentityConnected +} +} -impl __sdk::spacetime_module::InModule for IdentityConnected { +impl __sdk::InModule for IdentityConnectedArgs { type Module = super::RemoteModule; } -pub struct IdentityConnectedCallbackId(__sdk::callbacks::CallbackId); +pub struct IdentityConnectedCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `__identity_connected__`. @@ -605,19 +687,30 @@ pub trait identity_connected { impl identity_connected for super::RemoteReducers { fn identity_connected(&self, ) -> __anyhow::Result<()> { - self.imp.call_reducer("__identity_connected__", IdentityConnected { }) + self.imp.call_reducer("__identity_connected__", IdentityConnectedArgs { }) } fn on_identity_connected( &self, mut callback: impl FnMut(&super::EventContext, ) + Send + 'static, ) -> IdentityConnectedCallbackId { - IdentityConnectedCallbackId(self.imp.on_reducer::( + IdentityConnectedCallbackId(self.imp.on_reducer( "__identity_connected__", - Box::new(move |ctx: &super::EventContext, args: &IdentityConnected| callback(ctx, )), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::IdentityConnected { + + }, + .. + }), + .. + } = ctx else { unreachable!() }; + callback(ctx, ) + }), )) } fn remove_on_identity_connected(&self, callback: IdentityConnectedCallbackId) { - self.imp.remove_on_reducer::("__identity_connected__", callback.0) + self.imp.remove_on_reducer("__identity_connected__", callback.0) } } @@ -646,26 +739,31 @@ impl set_flags_for_identity_connected for super::SetReducerFlags { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct Init { +pub(super) struct InitArgs { } +impl From for super::Reducer { + fn from(args: InitArgs) -> Self { + Self::Init +} +} -impl __sdk::spacetime_module::InModule for Init { +impl __sdk::InModule for InitArgs { type Module = super::RemoteModule; } -pub struct InitCallbackId(__sdk::callbacks::CallbackId); +pub struct InitCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `__init__`. @@ -696,19 +794,30 @@ pub trait init { impl init for super::RemoteReducers { fn init(&self, ) -> __anyhow::Result<()> { - self.imp.call_reducer("__init__", Init { }) + self.imp.call_reducer("__init__", InitArgs { }) } fn on_init( &self, mut callback: impl FnMut(&super::EventContext, ) + Send + 'static, ) -> InitCallbackId { - InitCallbackId(self.imp.on_reducer::( + InitCallbackId(self.imp.on_reducer( "__init__", - Box::new(move |ctx: &super::EventContext, args: &Init| callback(ctx, )), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::Init { + + }, + .. + }), + .. + } = ctx else { unreachable!() }; + callback(ctx, ) + }), )) } fn remove_on_init(&self, callback: InitCallbackId) { - self.imp.remove_on_reducer::("__init__", callback.0) + self.imp.remove_on_reducer("__init__", callback.0) } } @@ -737,12 +846,12 @@ impl set_flags_for_init for super::SetReducerFlags { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; pub mod baz_type; @@ -779,30 +888,20 @@ pub mod test_d_table; pub mod test_e_table; pub mod test_f_table; -pub use baz_type::*; -pub use foobar_type::*; -pub use has_special_stuff_type::*; -pub use namespace_test_c_type::*; -pub use namespace_test_f_type::*; -pub use pk_multi_identity_type::*; -pub use point_type::*; -pub use private_type::*; -pub use repeating_test_arg_type::*; -pub use test_a_type::*; -pub use test_b_type::*; -pub use test_d_type::*; -pub use test_e_type::*; -pub use test_foobar_type::*; -pub use add_player_reducer::*; -pub use add_private_reducer::*; -pub use delete_player_reducer::*; -pub use delete_players_by_name_reducer::*; -pub use identity_connected_reducer::*; -pub use init_reducer::*; -pub use query_private_reducer::*; -pub use repeating_test_reducer::*; -pub use test_btree_index_args_reducer::*; -pub use test_reducer::*; +pub use baz_type::Baz; +pub use foobar_type::Foobar; +pub use has_special_stuff_type::HasSpecialStuff; +pub use pk_multi_identity_type::PkMultiIdentity; +pub use point_type::Point; +pub use private_type::Private; +pub use repeating_test_arg_type::RepeatingTestArg; +pub use test_a_type::TestA; +pub use test_b_type::TestB; +pub use test_d_type::TestD; +pub use test_e_type::TestE; +pub use test_foobar_type::TestFoobar; +pub use namespace_test_c_type::NamespaceTestC; +pub use namespace_test_f_type::NamespaceTestF; pub use has_special_stuff_table::*; pub use pk_multi_identity_table::*; pub use points_table::*; @@ -812,9 +911,18 @@ pub use test_a_table::*; pub use test_d_table::*; pub use test_e_table::*; pub use test_f_table::*; - -#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] -#[sats(crate = __lib)] +pub use identity_connected_reducer::{identity_connected, set_flags_for_identity_connected, IdentityConnectedCallbackId}; +pub use init_reducer::{init, set_flags_for_init, InitCallbackId}; +pub use add_player_reducer::{add_player, set_flags_for_add_player, AddPlayerCallbackId}; +pub use add_private_reducer::{add_private, set_flags_for_add_private, AddPrivateCallbackId}; +pub use delete_player_reducer::{delete_player, set_flags_for_delete_player, DeletePlayerCallbackId}; +pub use delete_players_by_name_reducer::{delete_players_by_name, set_flags_for_delete_players_by_name, DeletePlayersByNameCallbackId}; +pub use query_private_reducer::{query_private, set_flags_for_query_private, QueryPrivateCallbackId}; +pub use repeating_test_reducer::{repeating_test, set_flags_for_repeating_test, RepeatingTestCallbackId}; +pub use test_reducer::{test, set_flags_for_test, TestCallbackId}; +pub use test_btree_index_args_reducer::{test_btree_index_args, set_flags_for_test_btree_index_args, TestBtreeIndexArgsCallbackId}; + +#[derive(Clone, PartialEq, Debug)] /// One of the reducers defined by this module. /// @@ -822,50 +930,51 @@ pub use test_f_table::*; /// to indicate which reducer caused the event. pub enum Reducer { - IdentityConnected(identity_connected_reducer::IdentityConnected), - Init(init_reducer::Init), - AddPlayer(add_player_reducer::AddPlayer), - AddPrivate(add_private_reducer::AddPrivate), - DeletePlayer(delete_player_reducer::DeletePlayer), - DeletePlayersByName(delete_players_by_name_reducer::DeletePlayersByName), - QueryPrivate(query_private_reducer::QueryPrivate), - RepeatingTest(repeating_test_reducer::RepeatingTest), - Test(test_reducer::Test), - TestBtreeIndexArgs(test_btree_index_args_reducer::TestBtreeIndexArgs), -} - - -impl __sdk::spacetime_module::InModule for Reducer { + IdentityConnected , + Init , + AddPlayer { + name: String, +} , + AddPrivate { + name: String, +} , + DeletePlayer { + id: u64, +} , + DeletePlayersByName { + name: String, +} , + QueryPrivate , + RepeatingTest { + arg: RepeatingTestArg, +} , + Test { + arg: TestA, + arg_2: TestB, + arg_3: NamespaceTestC, + arg_4: NamespaceTestF, +} , + TestBtreeIndexArgs , +} + + +impl __sdk::InModule for Reducer { type Module = RemoteModule; } -impl __sdk::spacetime_module::Reducer for Reducer { +impl __sdk::Reducer for Reducer { fn reducer_name(&self) -> &'static str { match self { - Reducer::IdentityConnected(_) => "__identity_connected__", - Reducer::Init(_) => "__init__", - Reducer::AddPlayer(_) => "add_player", - Reducer::AddPrivate(_) => "add_private", - Reducer::DeletePlayer(_) => "delete_player", - Reducer::DeletePlayersByName(_) => "delete_players_by_name", - Reducer::QueryPrivate(_) => "query_private", - Reducer::RepeatingTest(_) => "repeating_test", - Reducer::Test(_) => "test", - Reducer::TestBtreeIndexArgs(_) => "test_btree_index_args", -} -} -fn reducer_args(&self) -> &dyn std::any::Any { - match self { - Reducer::IdentityConnected(args) => args, - Reducer::Init(args) => args, - Reducer::AddPlayer(args) => args, - Reducer::AddPrivate(args) => args, - Reducer::DeletePlayer(args) => args, - Reducer::DeletePlayersByName(args) => args, - Reducer::QueryPrivate(args) => args, - Reducer::RepeatingTest(args) => args, - Reducer::Test(args) => args, - Reducer::TestBtreeIndexArgs(args) => args, + Reducer::IdentityConnected => "__identity_connected__", + Reducer::Init => "__init__", + Reducer::AddPlayer { .. } => "add_player", + Reducer::AddPrivate { .. } => "add_private", + Reducer::DeletePlayer { .. } => "delete_player", + Reducer::DeletePlayersByName { .. } => "delete_players_by_name", + Reducer::QueryPrivate => "query_private", + Reducer::RepeatingTest { .. } => "repeating_test", + Reducer::Test { .. } => "test", + Reducer::TestBtreeIndexArgs => "test_btree_index_args", } } } @@ -873,16 +982,16 @@ impl TryFrom<__ws::ReducerCallInfo<__ws::BsatnFormat>> for Reducer { type Error = __anyhow::Error; fn try_from(value: __ws::ReducerCallInfo<__ws::BsatnFormat>) -> __anyhow::Result { match &value.reducer_name[..] { - "__identity_connected__" => Ok(Reducer::IdentityConnected(__sdk::spacetime_module::parse_reducer_args("__identity_connected__", &value.args)?)), - "__init__" => Ok(Reducer::Init(__sdk::spacetime_module::parse_reducer_args("__init__", &value.args)?)), - "add_player" => Ok(Reducer::AddPlayer(__sdk::spacetime_module::parse_reducer_args("add_player", &value.args)?)), - "add_private" => Ok(Reducer::AddPrivate(__sdk::spacetime_module::parse_reducer_args("add_private", &value.args)?)), - "delete_player" => Ok(Reducer::DeletePlayer(__sdk::spacetime_module::parse_reducer_args("delete_player", &value.args)?)), - "delete_players_by_name" => Ok(Reducer::DeletePlayersByName(__sdk::spacetime_module::parse_reducer_args("delete_players_by_name", &value.args)?)), - "query_private" => Ok(Reducer::QueryPrivate(__sdk::spacetime_module::parse_reducer_args("query_private", &value.args)?)), - "repeating_test" => Ok(Reducer::RepeatingTest(__sdk::spacetime_module::parse_reducer_args("repeating_test", &value.args)?)), - "test" => Ok(Reducer::Test(__sdk::spacetime_module::parse_reducer_args("test", &value.args)?)), - "test_btree_index_args" => Ok(Reducer::TestBtreeIndexArgs(__sdk::spacetime_module::parse_reducer_args("test_btree_index_args", &value.args)?)), + "__identity_connected__" => Ok(__sdk::parse_reducer_args::("__identity_connected__", &value.args)?.into()), + "__init__" => Ok(__sdk::parse_reducer_args::("__init__", &value.args)?.into()), + "add_player" => Ok(__sdk::parse_reducer_args::("add_player", &value.args)?.into()), + "add_private" => Ok(__sdk::parse_reducer_args::("add_private", &value.args)?.into()), + "delete_player" => Ok(__sdk::parse_reducer_args::("delete_player", &value.args)?.into()), + "delete_players_by_name" => Ok(__sdk::parse_reducer_args::("delete_players_by_name", &value.args)?.into()), + "query_private" => Ok(__sdk::parse_reducer_args::("query_private", &value.args)?.into()), + "repeating_test" => Ok(__sdk::parse_reducer_args::("repeating_test", &value.args)?.into()), + "test" => Ok(__sdk::parse_reducer_args::("test", &value.args)?.into()), + "test_btree_index_args" => Ok(__sdk::parse_reducer_args::("test_btree_index_args", &value.args)?.into()), _ => Err(__anyhow::anyhow!("Unknown reducer {:?}", value.reducer_name)), } } @@ -892,15 +1001,15 @@ fn try_from(value: __ws::ReducerCallInfo<__ws::BsatnFormat>) -> __anyhow::Result #[allow(non_snake_case)] #[doc(hidden)] pub struct DbUpdate { - has_special_stuff: __sdk::spacetime_module::TableUpdate, - pk_multi_identity: __sdk::spacetime_module::TableUpdate, - points: __sdk::spacetime_module::TableUpdate, - private: __sdk::spacetime_module::TableUpdate, - repeating_test_arg: __sdk::spacetime_module::TableUpdate, - test_a: __sdk::spacetime_module::TableUpdate, - test_d: __sdk::spacetime_module::TableUpdate, - test_e: __sdk::spacetime_module::TableUpdate, - test_f: __sdk::spacetime_module::TableUpdate, + has_special_stuff: __sdk::TableUpdate, + pk_multi_identity: __sdk::TableUpdate, + points: __sdk::TableUpdate, + private: __sdk::TableUpdate, + repeating_test_arg: __sdk::TableUpdate, + test_a: __sdk::TableUpdate, + test_d: __sdk::TableUpdate, + test_e: __sdk::TableUpdate, + test_f: __sdk::TableUpdate, } @@ -928,12 +1037,12 @@ impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate { } } -impl __sdk::spacetime_module::InModule for DbUpdate { +impl __sdk::InModule for DbUpdate { type Module = RemoteModule; } -impl __sdk::spacetime_module::DbUpdate for DbUpdate { - fn apply_to_client_cache(&self, cache: &mut __sdk::client_cache::ClientCache) { +impl __sdk::DbUpdate for DbUpdate { + fn apply_to_client_cache(&self, cache: &mut __sdk::ClientCache) { cache.apply_diff_to_table::("has_special_stuff", &self.has_special_stuff); cache.apply_diff_to_table::("pk_multi_identity", &self.pk_multi_identity); cache.apply_diff_to_table::("points", &self.points); @@ -944,7 +1053,7 @@ impl __sdk::spacetime_module::DbUpdate for DbUpdate { cache.apply_diff_to_table::("test_e", &self.test_e); cache.apply_diff_to_table::("test_f", &self.test_f); } -fn invoke_row_callbacks(&self, event: &EventContext, callbacks: &mut __sdk::callbacks::DbCallbacks) { +fn invoke_row_callbacks(&self, event: &EventContext, callbacks: &mut __sdk::DbCallbacks) { callbacks.invoke_table_row_callbacks::("has_special_stuff", &self.has_special_stuff, event); callbacks.invoke_table_row_callbacks::("pk_multi_identity", &self.pk_multi_identity, event); callbacks.invoke_table_row_callbacks::("points", &self.points, event); @@ -961,28 +1070,17 @@ fn invoke_row_callbacks(&self, event: &EventContext, callbacks: &mut __sdk::call #[doc(hidden)] pub struct RemoteModule; -impl __sdk::spacetime_module::InModule for RemoteModule { +impl __sdk::InModule for RemoteModule { type Module = Self; } -impl __sdk::spacetime_module::SpacetimeModule for RemoteModule { - type DbConnection = DbConnection; - type EventContext = EventContext; - type Reducer = Reducer; - type DbView = RemoteTables; - type Reducers = RemoteReducers; - type SetReducerFlags = SetReducerFlags; - type DbUpdate = DbUpdate; - type SubscriptionHandle = SubscriptionHandle; -} - /// The `reducers` field of [`EventContext`] and [`DbConnection`], /// with methods provided by extension traits for each reducer defined by the module. pub struct RemoteReducers { - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for RemoteReducers { +impl __sdk::InModule for RemoteReducers { type Module = RemoteModule; } @@ -993,20 +1091,20 @@ impl __sdk::spacetime_module::InModule for RemoteReducers { /// /// This type is currently unstable and may be removed without a major version bump. pub struct SetReducerFlags { - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for SetReducerFlags { +impl __sdk::InModule for SetReducerFlags { type Module = RemoteModule; } /// The `db` field of [`EventContext`] and [`DbConnection`], /// with methods provided by extension traits for each table defined by the module. pub struct RemoteTables { - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for RemoteTables { +impl __sdk::InModule for RemoteTables { type Module = RemoteModule; } @@ -1038,14 +1136,14 @@ pub struct DbConnection { /// This type is currently unstable and may be removed without a major version bump. pub set_reducer_flags: SetReducerFlags, - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for DbConnection { +impl __sdk::InModule for DbConnection { type Module = RemoteModule; } -impl __sdk::db_context::DbContext for DbConnection { +impl __sdk::DbContext for DbConnection { type DbView = RemoteTables; type Reducers = RemoteReducers; type SetReducerFlags = SetReducerFlags; @@ -1068,10 +1166,10 @@ impl __sdk::db_context::DbContext for DbConnection { self.imp.disconnect() } - type SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder; + type SubscriptionBuilder = __sdk::SubscriptionBuilder; fn subscription_builder(&self) -> Self::SubscriptionBuilder { - __sdk::subscription::SubscriptionBuilder::new(&self.imp) + __sdk::SubscriptionBuilder::new(&self.imp) } fn try_identity(&self) -> Option<__sdk::Identity> { @@ -1087,7 +1185,7 @@ impl DbConnection { /// /// See [`__sdk::DbConnectionBuilder`] for required and optional configuration for the new connection. pub fn builder() -> __sdk::DbConnectionBuilder { - __sdk::db_connection::DbConnectionBuilder::new() + __sdk::DbConnectionBuilder::new() } /// If any WebSocket messages are waiting, process one of them. @@ -1153,8 +1251,8 @@ impl DbConnection { } } -impl __sdk::spacetime_module::DbConnection for DbConnection { - fn new(imp: __sdk::db_connection::DbContextImpl) -> Self { +impl __sdk::DbConnection for DbConnection { + fn new(imp: __sdk::DbContextImpl) -> Self { Self { db: RemoteTables { imp: imp.clone() }, reducers: RemoteReducers { imp: imp.clone() }, @@ -1177,15 +1275,15 @@ pub struct EventContext { /// This type is currently unstable and may be removed without a major version bump. pub set_reducer_flags: SetReducerFlags, /// The event which caused these callbacks to run. - pub event: __sdk::event::Event, - imp: __sdk::db_connection::DbContextImpl, + pub event: __sdk::Event, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for EventContext { +impl __sdk::InModule for EventContext { type Module = RemoteModule; } -impl __sdk::db_context::DbContext for EventContext { +impl __sdk::DbContext for EventContext { type DbView = RemoteTables; type Reducers = RemoteReducers; type SetReducerFlags = SetReducerFlags; @@ -1204,14 +1302,14 @@ impl __sdk::db_context::DbContext for EventContext { self.imp.is_active() } - fn disconnect(&self) -> spacetimedb_sdk::anyhow::Result<()> { + fn disconnect(&self) -> __anyhow::Result<()> { self.imp.disconnect() } - type SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder; + type SubscriptionBuilder = __sdk::SubscriptionBuilder; fn subscription_builder(&self) -> Self::SubscriptionBuilder { - __sdk::subscription::SubscriptionBuilder::new(&self.imp) + __sdk::SubscriptionBuilder::new(&self.imp) } fn try_identity(&self) -> Option<__sdk::Identity> { @@ -1222,11 +1320,11 @@ impl __sdk::db_context::DbContext for EventContext { } } -impl __sdk::spacetime_module::EventContext for EventContext { - fn event(&self) -> &__sdk::event::Event { +impl __sdk::EventContext for EventContext { + fn event(&self) -> &__sdk::Event { &self.event } - fn new(imp: __sdk::db_connection::DbContextImpl, event: __sdk::event::Event) -> Self { + fn new(imp: __sdk::DbContextImpl, event: __sdk::Event) -> Self { Self { db: RemoteTables { imp: imp.clone() }, reducers: RemoteReducers { imp: imp.clone() }, @@ -1240,15 +1338,15 @@ impl __sdk::spacetime_module::EventContext for EventContext { /// A handle on a subscribed query. // TODO: Document this better after implementing the new subscription API. pub struct SubscriptionHandle { - imp: __sdk::subscription::SubscriptionHandleImpl, + imp: __sdk::SubscriptionHandleImpl, } -impl __sdk::spacetime_module::InModule for SubscriptionHandle { +impl __sdk::InModule for SubscriptionHandle { type Module = RemoteModule; } -impl __sdk::spacetime_module::SubscriptionHandle for SubscriptionHandle { - fn new(imp: __sdk::subscription::SubscriptionHandleImpl) -> Self { +impl __sdk::SubscriptionHandle for SubscriptionHandle { + fn new(imp: __sdk::SubscriptionHandleImpl) -> Self { Self { imp } } } @@ -1262,26 +1360,50 @@ pub trait RemoteDbContext: __sdk::DbContext< DbView = RemoteTables, Reducers = RemoteReducers, SetReducerFlags = SetReducerFlags, - SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder, + SubscriptionBuilder = __sdk::SubscriptionBuilder, > {} impl, + SubscriptionBuilder = __sdk::SubscriptionBuilder, >> RemoteDbContext for Ctx {} + +impl __sdk::SpacetimeModule for RemoteModule { + + type DbConnection = DbConnection; + type EventContext = EventContext; + type Reducer = Reducer; + type DbView = RemoteTables; + type Reducers = RemoteReducers; + type SetReducerFlags = SetReducerFlags; + type DbUpdate = DbUpdate; + type SubscriptionHandle = SubscriptionHandle; + +fn register_tables(client_cache: &mut __sdk::ClientCache) { + has_special_stuff_table::register_table(client_cache); + pk_multi_identity_table::register_table(client_cache); + points_table::register_table(client_cache); + private_table::register_table(client_cache); + repeating_test_arg_table::register_table(client_cache); + test_a_table::register_table(client_cache); + test_d_table::register_table(client_cache); + test_e_table::register_table(client_cache); + test_f_table::register_table(client_cache); +} +} ''' "namespace_test_c_type.rs" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -1295,7 +1417,7 @@ pub enum NamespaceTestC { -impl __sdk::spacetime_module::InModule for NamespaceTestC { +impl __sdk::InModule for NamespaceTestC { type Module = super::RemoteModule; } @@ -1304,12 +1426,12 @@ impl __sdk::spacetime_module::InModule for NamespaceTestC { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; @@ -1326,7 +1448,7 @@ pub enum NamespaceTestF { -impl __sdk::spacetime_module::InModule for NamespaceTestF { +impl __sdk::InModule for NamespaceTestF { type Module = super::RemoteModule; } @@ -1335,12 +1457,12 @@ impl __sdk::spacetime_module::InModule for NamespaceTestF { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; use super::pk_multi_identity_type::PkMultiIdentity; @@ -1353,7 +1475,7 @@ use super::pk_multi_identity_type::PkMultiIdentity; /// but to directly chain method calls, /// like `ctx.db.pk_multi_identity().on_insert(...)`. pub struct PkMultiIdentityTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -1376,10 +1498,10 @@ impl PkMultiIdentityTableAccess for super::RemoteTables { } } -pub struct PkMultiIdentityInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkMultiIdentityDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkMultiIdentityInsertCallbackId(__sdk::CallbackId); +pub struct PkMultiIdentityDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkMultiIdentityTableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkMultiIdentityTableHandle<'ctx> { type Row = PkMultiIdentity; type EventContext = super::EventContext; @@ -1413,9 +1535,16 @@ impl<'ctx> __sdk::table::Table for PkMultiIdentityTableHandle<'ctx> { } } -pub struct PkMultiIdentityUpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkMultiIdentityTableHandle<'ctx> { + let _table = client_cache.get_or_make_table::("pk_multi_identity"); + _table.add_unique_constraint::("id", |row| &row.id); + _table.add_unique_constraint::("other", |row| &row.other); +} +pub struct PkMultiIdentityUpdateCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::TableWithPrimaryKey for PkMultiIdentityTableHandle<'ctx> { type UpdateCallbackId = PkMultiIdentityUpdateCallbackId; fn on_update( @@ -1433,8 +1562,8 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkMultiIdentityTableHandle<'ctx #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::( +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::( raw_updates, |row: &PkMultiIdentity| &row.id, ).context("Failed to parse table update for table \"pk_multi_identity\"") @@ -1448,7 +1577,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_multi_identity().id().find(...)`. pub struct PkMultiIdentityIdUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -1456,7 +1585,7 @@ pub(super) fn parse_table_update( /// Get a handle on the `id` unique index on the table `pk_multi_identity`. pub fn id(&self) -> PkMultiIdentityIdUnique<'ctx> { PkMultiIdentityIdUnique { - imp: self.imp.get_unique_constraint::("id", |row| &row.id), + imp: self.imp.get_unique_constraint::("id"), phantom: std::marker::PhantomData, } } @@ -1478,7 +1607,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_multi_identity().other().find(...)`. pub struct PkMultiIdentityOtherUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -1486,7 +1615,7 @@ pub(super) fn parse_table_update( /// Get a handle on the `other` unique index on the table `pk_multi_identity`. pub fn other(&self) -> PkMultiIdentityOtherUnique<'ctx> { PkMultiIdentityOtherUnique { - imp: self.imp.get_unique_constraint::("other", |row| &row.other), + imp: self.imp.get_unique_constraint::("other"), phantom: std::marker::PhantomData, } } @@ -1504,12 +1633,12 @@ pub(super) fn parse_table_update( // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; @@ -1521,7 +1650,7 @@ pub struct PkMultiIdentity { } -impl __sdk::spacetime_module::InModule for PkMultiIdentity { +impl __sdk::InModule for PkMultiIdentity { type Module = super::RemoteModule; } @@ -1530,12 +1659,12 @@ impl __sdk::spacetime_module::InModule for PkMultiIdentity { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; @@ -1547,7 +1676,7 @@ pub struct Point { } -impl __sdk::spacetime_module::InModule for Point { +impl __sdk::InModule for Point { type Module = super::RemoteModule; } @@ -1556,12 +1685,12 @@ impl __sdk::spacetime_module::InModule for Point { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; use super::point_type::Point; @@ -1574,7 +1703,7 @@ use super::point_type::Point; /// but to directly chain method calls, /// like `ctx.db.points().on_insert(...)`. pub struct PointsTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -1597,10 +1726,10 @@ impl PointsTableAccess for super::RemoteTables { } } -pub struct PointsInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PointsDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PointsInsertCallbackId(__sdk::CallbackId); +pub struct PointsDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PointsTableHandle<'ctx> { +impl<'ctx> __sdk::Table for PointsTableHandle<'ctx> { type Row = Point; type EventContext = super::EventContext; @@ -1634,11 +1763,16 @@ impl<'ctx> __sdk::table::Table for PointsTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + + let _table = client_cache.get_or_make_table::("points"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"points\"") } ''' @@ -1646,12 +1780,12 @@ pub(super) fn parse_table_update( // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; use super::private_type::Private; @@ -1664,7 +1798,7 @@ use super::private_type::Private; /// but to directly chain method calls, /// like `ctx.db.private().on_insert(...)`. pub struct PrivateTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -1687,10 +1821,10 @@ impl PrivateTableAccess for super::RemoteTables { } } -pub struct PrivateInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PrivateDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PrivateInsertCallbackId(__sdk::CallbackId); +pub struct PrivateDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PrivateTableHandle<'ctx> { +impl<'ctx> __sdk::Table for PrivateTableHandle<'ctx> { type Row = Private; type EventContext = super::EventContext; @@ -1724,11 +1858,16 @@ impl<'ctx> __sdk::table::Table for PrivateTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + + let _table = client_cache.get_or_make_table::("private"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"private\"") } ''' @@ -1736,12 +1875,12 @@ pub(super) fn parse_table_update( // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; @@ -1752,7 +1891,7 @@ pub struct Private { } -impl __sdk::spacetime_module::InModule for Private { +impl __sdk::InModule for Private { type Module = super::RemoteModule; } @@ -1761,26 +1900,31 @@ impl __sdk::spacetime_module::InModule for Private { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct QueryPrivate { +pub(super) struct QueryPrivateArgs { } +impl From for super::Reducer { + fn from(args: QueryPrivateArgs) -> Self { + Self::QueryPrivate +} +} -impl __sdk::spacetime_module::InModule for QueryPrivate { +impl __sdk::InModule for QueryPrivateArgs { type Module = super::RemoteModule; } -pub struct QueryPrivateCallbackId(__sdk::callbacks::CallbackId); +pub struct QueryPrivateCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `query_private`. @@ -1811,19 +1955,30 @@ pub trait query_private { impl query_private for super::RemoteReducers { fn query_private(&self, ) -> __anyhow::Result<()> { - self.imp.call_reducer("query_private", QueryPrivate { }) + self.imp.call_reducer("query_private", QueryPrivateArgs { }) } fn on_query_private( &self, mut callback: impl FnMut(&super::EventContext, ) + Send + 'static, ) -> QueryPrivateCallbackId { - QueryPrivateCallbackId(self.imp.on_reducer::( + QueryPrivateCallbackId(self.imp.on_reducer( "query_private", - Box::new(move |ctx: &super::EventContext, args: &QueryPrivate| callback(ctx, )), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::QueryPrivate { + + }, + .. + }), + .. + } = ctx else { unreachable!() }; + callback(ctx, ) + }), )) } fn remove_on_query_private(&self, callback: QueryPrivateCallbackId) { - self.imp.remove_on_reducer::("query_private", callback.0) + self.imp.remove_on_reducer("query_private", callback.0) } } @@ -1852,12 +2007,12 @@ impl set_flags_for_query_private for super::SetReducerFlags { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; use super::repeating_test_arg_type::RepeatingTestArg; @@ -1870,7 +2025,7 @@ use super::repeating_test_arg_type::RepeatingTestArg; /// but to directly chain method calls, /// like `ctx.db.repeating_test_arg().on_insert(...)`. pub struct RepeatingTestArgTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -1893,10 +2048,10 @@ impl RepeatingTestArgTableAccess for super::RemoteTables { } } -pub struct RepeatingTestArgInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct RepeatingTestArgDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct RepeatingTestArgInsertCallbackId(__sdk::CallbackId); +pub struct RepeatingTestArgDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for RepeatingTestArgTableHandle<'ctx> { +impl<'ctx> __sdk::Table for RepeatingTestArgTableHandle<'ctx> { type Row = RepeatingTestArg; type EventContext = super::EventContext; @@ -1930,9 +2085,15 @@ impl<'ctx> __sdk::table::Table for RepeatingTestArgTableHandle<'ctx> { } } -pub struct RepeatingTestArgUpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { -impl<'ctx> __sdk::table::TableWithPrimaryKey for RepeatingTestArgTableHandle<'ctx> { + let _table = client_cache.get_or_make_table::("repeating_test_arg"); + _table.add_unique_constraint::("scheduled_id", |row| &row.scheduled_id); +} +pub struct RepeatingTestArgUpdateCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::TableWithPrimaryKey for RepeatingTestArgTableHandle<'ctx> { type UpdateCallbackId = RepeatingTestArgUpdateCallbackId; fn on_update( @@ -1950,8 +2111,8 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for RepeatingTestArgTableHandle<'ct #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::( +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::( raw_updates, |row: &RepeatingTestArg| &row.scheduled_id, ).context("Failed to parse table update for table \"repeating_test_arg\"") @@ -1965,7 +2126,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.repeating_test_arg().scheduled_id().find(...)`. pub struct RepeatingTestArgScheduledIdUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -1973,7 +2134,7 @@ pub(super) fn parse_table_update( /// Get a handle on the `scheduled_id` unique index on the table `repeating_test_arg`. pub fn scheduled_id(&self) -> RepeatingTestArgScheduledIdUnique<'ctx> { RepeatingTestArgScheduledIdUnique { - imp: self.imp.get_unique_constraint::("scheduled_id", |row| &row.scheduled_id), + imp: self.imp.get_unique_constraint::("scheduled_id"), phantom: std::marker::PhantomData, } } @@ -1991,25 +2152,25 @@ pub(super) fn parse_table_update( // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] pub struct RepeatingTestArg { - pub prev_time: u64, pub scheduled_id: u64, pub scheduled_at: __sdk::ScheduleAt, + pub prev_time: u64, } -impl __sdk::spacetime_module::InModule for RepeatingTestArg { +impl __sdk::InModule for RepeatingTestArg { type Module = super::RemoteModule; } @@ -2018,28 +2179,35 @@ impl __sdk::spacetime_module::InModule for RepeatingTestArg { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; use super::repeating_test_arg_type::RepeatingTestArg; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct RepeatingTest { +pub(super) struct RepeatingTestArgs { pub arg: RepeatingTestArg, } +impl From for super::Reducer { + fn from(args: RepeatingTestArgs) -> Self { + Self::RepeatingTest { + arg: args.arg, +} +} +} -impl __sdk::spacetime_module::InModule for RepeatingTest { +impl __sdk::InModule for RepeatingTestArgs { type Module = super::RemoteModule; } -pub struct RepeatingTestCallbackId(__sdk::callbacks::CallbackId); +pub struct RepeatingTestCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `repeating_test`. @@ -2072,19 +2240,30 @@ pub trait repeating_test { impl repeating_test for super::RemoteReducers { fn repeating_test(&self, arg: RepeatingTestArg, ) -> __anyhow::Result<()> { - self.imp.call_reducer("repeating_test", RepeatingTest { arg, }) + self.imp.call_reducer("repeating_test", RepeatingTestArgs { arg, }) } fn on_repeating_test( &self, mut callback: impl FnMut(&super::EventContext, &RepeatingTestArg, ) + Send + 'static, ) -> RepeatingTestCallbackId { - RepeatingTestCallbackId(self.imp.on_reducer::( + RepeatingTestCallbackId(self.imp.on_reducer( "repeating_test", - Box::new(move |ctx: &super::EventContext, args: &RepeatingTest| callback(ctx, &args.arg, )), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::RepeatingTest { + arg, + }, + .. + }), + .. + } = ctx else { unreachable!() }; + callback(ctx, arg, ) + }), )) } fn remove_on_repeating_test(&self, callback: RepeatingTestCallbackId) { - self.imp.remove_on_reducer::("repeating_test", callback.0) + self.imp.remove_on_reducer("repeating_test", callback.0) } } @@ -2113,12 +2292,12 @@ impl set_flags_for_repeating_test for super::SetReducerFlags { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; use super::test_a_type::TestA; @@ -2131,7 +2310,7 @@ use super::test_a_type::TestA; /// but to directly chain method calls, /// like `ctx.db.test_a().on_insert(...)`. pub struct TestATableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -2154,10 +2333,10 @@ impl TestATableAccess for super::RemoteTables { } } -pub struct TestAInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct TestADeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct TestAInsertCallbackId(__sdk::CallbackId); +pub struct TestADeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for TestATableHandle<'ctx> { +impl<'ctx> __sdk::Table for TestATableHandle<'ctx> { type Row = TestA; type EventContext = super::EventContext; @@ -2191,11 +2370,16 @@ impl<'ctx> __sdk::table::Table for TestATableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + + let _table = client_cache.get_or_make_table::("test_a"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"test_a\"") } ''' @@ -2203,12 +2387,12 @@ pub(super) fn parse_table_update( // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; @@ -2221,7 +2405,7 @@ pub struct TestA { } -impl __sdk::spacetime_module::InModule for TestA { +impl __sdk::InModule for TestA { type Module = super::RemoteModule; } @@ -2230,12 +2414,12 @@ impl __sdk::spacetime_module::InModule for TestA { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; @@ -2246,7 +2430,7 @@ pub struct TestB { } -impl __sdk::spacetime_module::InModule for TestB { +impl __sdk::InModule for TestB { type Module = super::RemoteModule; } @@ -2255,26 +2439,31 @@ impl __sdk::spacetime_module::InModule for TestB { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct TestBtreeIndexArgs { +pub(super) struct TestBtreeIndexArgsArgs { } +impl From for super::Reducer { + fn from(args: TestBtreeIndexArgsArgs) -> Self { + Self::TestBtreeIndexArgs +} +} -impl __sdk::spacetime_module::InModule for TestBtreeIndexArgs { +impl __sdk::InModule for TestBtreeIndexArgsArgs { type Module = super::RemoteModule; } -pub struct TestBtreeIndexArgsCallbackId(__sdk::callbacks::CallbackId); +pub struct TestBtreeIndexArgsCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `test_btree_index_args`. @@ -2305,19 +2494,30 @@ pub trait test_btree_index_args { impl test_btree_index_args for super::RemoteReducers { fn test_btree_index_args(&self, ) -> __anyhow::Result<()> { - self.imp.call_reducer("test_btree_index_args", TestBtreeIndexArgs { }) + self.imp.call_reducer("test_btree_index_args", TestBtreeIndexArgsArgs { }) } fn on_test_btree_index_args( &self, mut callback: impl FnMut(&super::EventContext, ) + Send + 'static, ) -> TestBtreeIndexArgsCallbackId { - TestBtreeIndexArgsCallbackId(self.imp.on_reducer::( + TestBtreeIndexArgsCallbackId(self.imp.on_reducer( "test_btree_index_args", - Box::new(move |ctx: &super::EventContext, args: &TestBtreeIndexArgs| callback(ctx, )), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::TestBtreeIndexArgs { + + }, + .. + }), + .. + } = ctx else { unreachable!() }; + callback(ctx, ) + }), )) } fn remove_on_test_btree_index_args(&self, callback: TestBtreeIndexArgsCallbackId) { - self.imp.remove_on_reducer::("test_btree_index_args", callback.0) + self.imp.remove_on_reducer("test_btree_index_args", callback.0) } } @@ -2346,12 +2546,12 @@ impl set_flags_for_test_btree_index_args for super::SetReducerFlags { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; use super::test_d_type::TestD; use super::namespace_test_c_type::NamespaceTestC; @@ -2365,7 +2565,7 @@ use super::namespace_test_c_type::NamespaceTestC; /// but to directly chain method calls, /// like `ctx.db.test_d().on_insert(...)`. pub struct TestDTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -2388,10 +2588,10 @@ impl TestDTableAccess for super::RemoteTables { } } -pub struct TestDInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct TestDDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct TestDInsertCallbackId(__sdk::CallbackId); +pub struct TestDDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for TestDTableHandle<'ctx> { +impl<'ctx> __sdk::Table for TestDTableHandle<'ctx> { type Row = TestD; type EventContext = super::EventContext; @@ -2425,11 +2625,16 @@ impl<'ctx> __sdk::table::Table for TestDTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + + let _table = client_cache.get_or_make_table::("test_d"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"test_d\"") } ''' @@ -2437,12 +2642,12 @@ pub(super) fn parse_table_update( // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; use super::namespace_test_c_type::NamespaceTestC; @@ -2454,7 +2659,7 @@ pub struct TestD { } -impl __sdk::spacetime_module::InModule for TestD { +impl __sdk::InModule for TestD { type Module = super::RemoteModule; } @@ -2463,12 +2668,12 @@ impl __sdk::spacetime_module::InModule for TestD { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; use super::test_e_type::TestE; @@ -2481,7 +2686,7 @@ use super::test_e_type::TestE; /// but to directly chain method calls, /// like `ctx.db.test_e().on_insert(...)`. pub struct TestETableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -2504,10 +2709,10 @@ impl TestETableAccess for super::RemoteTables { } } -pub struct TestEInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct TestEDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct TestEInsertCallbackId(__sdk::CallbackId); +pub struct TestEDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for TestETableHandle<'ctx> { +impl<'ctx> __sdk::Table for TestETableHandle<'ctx> { type Row = TestE; type EventContext = super::EventContext; @@ -2541,9 +2746,15 @@ impl<'ctx> __sdk::table::Table for TestETableHandle<'ctx> { } } -pub struct TestEUpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { -impl<'ctx> __sdk::table::TableWithPrimaryKey for TestETableHandle<'ctx> { + let _table = client_cache.get_or_make_table::("test_e"); + _table.add_unique_constraint::("id", |row| &row.id); +} +pub struct TestEUpdateCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::TableWithPrimaryKey for TestETableHandle<'ctx> { type UpdateCallbackId = TestEUpdateCallbackId; fn on_update( @@ -2561,8 +2772,8 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for TestETableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::( +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::( raw_updates, |row: &TestE| &row.id, ).context("Failed to parse table update for table \"test_e\"") @@ -2576,7 +2787,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.test_e().id().find(...)`. pub struct TestEIdUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -2584,7 +2795,7 @@ pub(super) fn parse_table_update( /// Get a handle on the `id` unique index on the table `test_e`. pub fn id(&self) -> TestEIdUnique<'ctx> { TestEIdUnique { - imp: self.imp.get_unique_constraint::("id", |row| &row.id), + imp: self.imp.get_unique_constraint::("id"), phantom: std::marker::PhantomData, } } @@ -2602,12 +2813,12 @@ pub(super) fn parse_table_update( // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; @@ -2619,7 +2830,7 @@ pub struct TestE { } -impl __sdk::spacetime_module::InModule for TestE { +impl __sdk::InModule for TestE { type Module = super::RemoteModule; } @@ -2628,12 +2839,12 @@ impl __sdk::spacetime_module::InModule for TestE { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; use super::test_foobar_type::TestFoobar; use super::foobar_type::Foobar; @@ -2647,7 +2858,7 @@ use super::foobar_type::Foobar; /// but to directly chain method calls, /// like `ctx.db.test_f().on_insert(...)`. pub struct TestFTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -2670,10 +2881,10 @@ impl TestFTableAccess for super::RemoteTables { } } -pub struct TestFInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct TestFDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct TestFInsertCallbackId(__sdk::CallbackId); +pub struct TestFDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for TestFTableHandle<'ctx> { +impl<'ctx> __sdk::Table for TestFTableHandle<'ctx> { type Row = TestFoobar; type EventContext = super::EventContext; @@ -2707,11 +2918,16 @@ impl<'ctx> __sdk::table::Table for TestFTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + + let _table = client_cache.get_or_make_table::("test_f"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"test_f\"") } ''' @@ -2719,12 +2935,12 @@ pub(super) fn parse_table_update( // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; use super::foobar_type::Foobar; @@ -2736,7 +2952,7 @@ pub struct TestFoobar { } -impl __sdk::spacetime_module::InModule for TestFoobar { +impl __sdk::InModule for TestFoobar { type Module = super::RemoteModule; } @@ -2745,12 +2961,12 @@ impl __sdk::spacetime_module::InModule for TestFoobar { // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. -#![allow(unused)]use spacetimedb_sdk::{ +#![allow(unused)]use spacetimedb_sdk::__codegen::{ self as __sdk, anyhow::{self as __anyhow, Context as _}, - lib as __lib, - sats as __sats, - ws_messages as __ws, + __lib, + __sats, + __ws, }; use super::test_a_type::TestA; @@ -2760,19 +2976,29 @@ use super::namespace_test_f_type::NamespaceTestF; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct Test { +pub(super) struct TestArgs { pub arg: TestA, pub arg_2: TestB, pub arg_3: NamespaceTestC, pub arg_4: NamespaceTestF, } +impl From for super::Reducer { + fn from(args: TestArgs) -> Self { + Self::Test { + arg: args.arg, + arg_2: args.arg_2, + arg_3: args.arg_3, + arg_4: args.arg_4, +} +} +} -impl __sdk::spacetime_module::InModule for Test { +impl __sdk::InModule for TestArgs { type Module = super::RemoteModule; } -pub struct TestCallbackId(__sdk::callbacks::CallbackId); +pub struct TestCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `test`. @@ -2811,19 +3037,30 @@ arg_2: TestB, arg_3: NamespaceTestC, arg_4: NamespaceTestF, ) -> __anyhow::Result<()> { - self.imp.call_reducer("test", Test { arg, arg_2, arg_3, arg_4, }) + self.imp.call_reducer("test", TestArgs { arg, arg_2, arg_3, arg_4, }) } fn on_test( &self, mut callback: impl FnMut(&super::EventContext, &TestA, &TestB, &NamespaceTestC, &NamespaceTestF, ) + Send + 'static, ) -> TestCallbackId { - TestCallbackId(self.imp.on_reducer::( + TestCallbackId(self.imp.on_reducer( "test", - Box::new(move |ctx: &super::EventContext, args: &Test| callback(ctx, &args.arg, &args.arg_2, &args.arg_3, &args.arg_4, )), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::Test { + arg, arg_2, arg_3, arg_4, + }, + .. + }), + .. + } = ctx else { unreachable!() }; + callback(ctx, arg, arg_2, arg_3, arg_4, ) + }), )) } fn remove_on_test(&self, callback: TestCallbackId) { - self.imp.remove_on_reducer::("test", callback.0) + self.imp.remove_on_reducer("test", callback.0) } } diff --git a/crates/cli/tests/snapshots/codegen__codegen_typescript.snap b/crates/cli/tests/snapshots/codegen__codegen_typescript.snap index f5bfd4c6a3a..df703fdc782 100644 --- a/crates/cli/tests/snapshots/codegen__codegen_typescript.snap +++ b/crates/cli/tests/snapshots/codegen__codegen_typescript.snap @@ -2165,9 +2165,9 @@ import { deepEqual, } from "@clockworklabs/spacetimedb-sdk"; export type RepeatingTestArg = { - prevTime: bigint, scheduledId: bigint, scheduledAt: { tag: "Interval", value: bigint } | { tag: "Time", value: bigint }, + prevTime: bigint, }; /** @@ -2180,9 +2180,9 @@ export namespace RepeatingTestArg { */ export function getTypeScriptAlgebraicType(): AlgebraicType { return AlgebraicType.createProductType([ - new ProductTypeElement("prevTime", AlgebraicType.createU64Type()), new ProductTypeElement("scheduledId", AlgebraicType.createU64Type()), new ProductTypeElement("scheduledAt", AlgebraicType.createScheduleAtType()), + new ProductTypeElement("prevTime", AlgebraicType.createU64Type()), ]); } diff --git a/crates/client-api/src/routes/identity.rs b/crates/client-api/src/routes/identity.rs index 8ab1e8c4a71..9169a8fd3d0 100644 --- a/crates/client-api/src/routes/identity.rs +++ b/crates/client-api/src/routes/identity.rs @@ -58,7 +58,7 @@ impl IdentityForUrl { impl<'de> serde::Deserialize<'de> for IdentityForUrl { fn deserialize>(de: D) -> Result { - <_>::deserialize(de).map(|DeserializeWrapper(b)| IdentityForUrl(Identity::from_byte_array(b))) + <_>::deserialize(de).map(|DeserializeWrapper(b)| IdentityForUrl(Identity::from_be_byte_array(b))) } } diff --git a/crates/core/src/host/wasmtime/wasmtime_module.rs b/crates/core/src/host/wasmtime/wasmtime_module.rs index 888693df989..1b539d2e8ad 100644 --- a/crates/core/src/host/wasmtime/wasmtime_module.rs +++ b/crates/core/src/host/wasmtime/wasmtime_module.rs @@ -193,7 +193,7 @@ impl module_host_actor::WasmInstance for WasmtimeInstance { // otherwise, we'd return something like `used: i128::MAX - u64::MAX`, which is inaccurate. set_store_fuel(store, budget.into()); - // Prepare sender identity and address. + // Prepare sender identity and address, as LITTLE-ENDIAN byte arrays. let [sender_0, sender_1, sender_2, sender_3] = bytemuck::must_cast(op.caller_identity.to_byte_array()); let [address_0, address_1] = bytemuck::must_cast(op.caller_address.as_byte_array()); diff --git a/crates/lib/proptest-regressions/identity.txt b/crates/lib/proptest-regressions/identity.txt new file mode 100644 index 00000000000..dbada4842a4 --- /dev/null +++ b/crates/lib/proptest-regressions/identity.txt @@ -0,0 +1,7 @@ +# Seeds for failure cases proptest has generated in the past. It is +# automatically read and these particular cases re-run before any +# novel cases are generated. +# +# It is recommended to check this file in to source control so that +# everyone who runs the test benefits from these saved cases. +cc 28ebdabf28ac09f38e0e0ddd728d32273f0dcffd43fa53bf1eaa8a01d1b38d90 # shrinks to w0 = 0, w1 = 1 diff --git a/crates/lib/src/address.rs b/crates/lib/src/address.rs index f08f14b7b90..4eaec6e5401 100644 --- a/crates/lib/src/address.rs +++ b/crates/lib/src/address.rs @@ -13,6 +13,21 @@ use spacetimedb_sats::{impl_deserialize, impl_serialize, impl_st, AlgebraicType, /// /// This is a special type. /// +/// An `Address` is a 128-bit unsigned integer. This can be serialized in various ways. +/// - In JSON, an `Address` is represented as a BARE DECIMAL number. This requires some care when deserializing: +/// see https://stackoverflow.com/questions/69644298/how-to-make-json-parse-to-treat-all-the-numbers-as-bigint +/// - In BSATN, an `Address` is represented as a LITTLE-ENDIAN number 16 bytes long. +/// - In memory, an `Address` is stored as a 128-bit number with the endianness of the host system. +/// +/// If you are manually converting a hexadecimal string to a byte array like so: +/// ```ignore +/// "0xb0b1b2..." +/// -> +/// [0xb0, 0xb1, 0xb2, ...] +/// ``` +/// Make sure you call `Address::from_be_byte_array` and NOT `Address::from_byte_array`. +/// The standard way of writing hexadecimal numbers follows a big-endian convention, if you +/// index the characters in written text in increasing order from left to right. // TODO: Evaluate other possible names: `DatabaseAddress`, `SPAddress` // TODO: Evaluate replacing this with a literal Ipv6Address // which is assigned permanently to a database. @@ -60,37 +75,67 @@ impl Address { self.__address__ } + /// Create an `Address` from a LITTLE-ENDIAN byte array. + /// + /// If you are parsing an `Address` from a string, you probably want `from_be_byte_array` instead. pub const fn from_byte_array(arr: [u8; 16]) -> Self { Self::from_u128(u128::from_le_bytes(arr)) } + /// Create an `Address` from a BIG-ENDIAN byte array. + /// + /// This method is the correct choice if you have converted the bytes of a hexadecimal-formatted `Address` + /// to a byte array in the following way: + /// + /// ```ignore + /// "0xb0b1b2..." + /// -> + /// [0xb0, 0xb1, 0xb2, ...] + /// ``` + pub const fn from_be_byte_array(arr: [u8; 16]) -> Self { + Self::from_u128(u128::from_be_bytes(arr)) + } + + /// Convert an address to a LITTLE-ENDIAN byte array. + /// If you are converting to a hexadecimal string, use `as_be_byte_array` instead. pub const fn as_byte_array(&self) -> [u8; 16] { self.__address__.to_le_bytes() } + /// Convert an address to a BIG-ENDIAN byte array. + /// This is a format suitable for printing as a hexadecimal string. + pub const fn as_be_byte_array(&self) -> [u8; 16] { + self.__address__.to_be_bytes() + } + pub fn from_hex(hex: &str) -> Result { from_hex_pad::<[u8; 16], _>(hex) .context("Addresses must be 32 hex characters (16 bytes) in length.") - .map(Self::from_byte_array) + .map(Self::from_be_byte_array) } + /// Convert this `Address` to a hexadecimal string. pub fn to_hex(self) -> HexString<16> { - spacetimedb_sats::hex::encode(&self.as_byte_array()) + spacetimedb_sats::hex::encode(&self.as_be_byte_array()) } + /// Extract the first 8 bytes of this `Address` as if it was stored in BIG-ENDIAN + /// format. (That is, the most significant bytes.) pub fn abbreviate(&self) -> [u8; 8] { - self.as_byte_array()[..8].try_into().unwrap() + self.as_be_byte_array()[..8].try_into().unwrap() } + /// Extract the first 16 characters of this `Address`'s hexadecimal representation. pub fn to_abbreviated_hex(self) -> HexString<8> { spacetimedb_sats::hex::encode(&self.abbreviate()) } + /// Create an `Address` from a slice, assumed to be in big-endian format. pub fn from_slice(slice: impl AsRef<[u8]>) -> Self { let slice = slice.as_ref(); let mut dst = [0u8; 16]; dst.copy_from_slice(slice); - Self::from_byte_array(dst) + Self::from_be_byte_array(dst) } pub fn to_ipv6(self) -> Ipv6Addr { @@ -147,7 +192,7 @@ impl serde::Serialize for AddressForUrl { where S: serde::Serializer, { - spacetimedb_sats::ser::serde::serialize_to(&Address::from(*self).as_byte_array(), serializer) + spacetimedb_sats::ser::serde::serialize_to(&Address::from(*self).as_be_byte_array(), serializer) } } @@ -158,7 +203,7 @@ impl<'de> serde::Deserialize<'de> for AddressForUrl { D: serde::Deserializer<'de>, { let arr = spacetimedb_sats::de::serde::deserialize_from(deserializer)?; - Ok(Address::from_byte_array(arr).into()) + Ok(Address::from_be_byte_array(arr).into()) } } @@ -168,7 +213,7 @@ impl serde::Serialize for Address { where S: serde::Serializer, { - spacetimedb_sats::ser::serde::serialize_to(&self.as_byte_array(), serializer) + spacetimedb_sats::ser::serde::serialize_to(&self.as_be_byte_array(), serializer) } } @@ -179,7 +224,7 @@ impl<'de> serde::Deserialize<'de> for Address { D: serde::Deserializer<'de>, { let arr = spacetimedb_sats::de::serde::deserialize_from(deserializer)?; - Ok(Address::from_byte_array(arr)) + Ok(Address::from_be_byte_array(arr)) } } @@ -188,8 +233,44 @@ mod tests { use super::*; use proptest::prelude::*; use spacetimedb_sats::bsatn; + use spacetimedb_sats::ser::serde::SerializeWrapper; use spacetimedb_sats::GroundSpacetimeType as _; + #[test] + fn address_json_serialization_big_endian() { + let addr = Address::from_be_byte_array([0xff, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); + + let hex = addr.to_hex(); + assert!( + hex.as_str().starts_with("ff01"), + "expected {hex:?} to start with \"ff01\"" + ); + + let json1 = serde_json::to_string(&addr).unwrap(); + let json2 = serde_json::to_string(&AddressForUrl::from(addr)).unwrap(); + + assert!( + json1.contains(hex.as_str()), + "expected {json1} to contain {hex} but it didn't" + ); + assert!( + json2.contains(hex.as_str()), + "expected {json2} to contain {hex} but it didn't" + ); + + // Serde made the slightly odd choice to serialize u128 as decimals in JSON. + // So we have an incompatibility between our formats here :/ + // The implementation of serialization for `sats` types via `SerializeWrapper` just calls + // the `serde` implementation to serialize primitives, so we can't fix this + // unless we make a custom implementation of `Serialize` and `Deserialize` for `Address`. + let decimal = addr.to_u128().to_string(); + let json3 = serde_json::to_string(SerializeWrapper::from_ref(&addr)).unwrap(); + assert!( + json3.contains(decimal.as_str()), + "expected {json3} to contain {decimal} but it didn't" + ); + } + proptest! { #[test] fn test_bsatn_roundtrip(val: u128) { @@ -198,6 +279,15 @@ mod tests { let de = bsatn::from_slice(&ser).unwrap(); assert_eq!(addr, de); } + + #[test] + fn address_conversions(a: u128) { + let v = Address::from_u128(a); + + prop_assert_eq!(Address::from_byte_array(v.as_byte_array()), v); + prop_assert_eq!(Address::from_be_byte_array(v.as_be_byte_array()), v); + prop_assert_eq!(Address::from_hex(v.to_hex().as_str()).unwrap(), v); + } } #[test] diff --git a/crates/lib/src/identity.rs b/crates/lib/src/identity.rs index eed44fa74ee..0cc0e2dbdfa 100644 --- a/crates/lib/src/identity.rs +++ b/crates/lib/src/identity.rs @@ -31,9 +31,22 @@ impl AuthCtx { } } -/// An identifier for something interacting with the database. +/// An `Identity` for something interacting with the database. /// -/// This is a special type. +/// An `Identity` is a 256-bit unsigned integer. These are encoded in various ways. +/// - In JSON, an `Identity` is represented as a hexadecimal number wrapped in a string, `"0x[64 hex characters]"`. +/// - In BSATN, an `Identity` is represented as a LITTLE-ENDIAN number 32 bytes long. +/// - In memory, an `Identity` is stored as a 256-bit number with the endianness of the host system. +/// +/// If you are manually converting a hexadecimal string to a byte array like so: +/// ```ignore +/// "0xb0b1b2..." +/// -> +/// [0xb0, 0xb1, 0xb2, ...] +/// ``` +/// Make sure you call `Identity::from_be_byte_array` and NOT `Identity::from_byte_array`. +/// The standard way of writing hexadecimal numbers follows a big-endian convention, if you +/// index the characters in written text in increasing order from left to right. #[derive(Default, Eq, PartialEq, PartialOrd, Ord, Clone, Copy, Hash, Serialize, Deserialize)] pub struct Identity { __identity__: u256, @@ -51,13 +64,30 @@ impl spacetimedb_metrics::typed_prometheus::AsPrometheusLabel for Identity { impl Identity { pub const ZERO: Self = Self::from_u256(u256::ZERO); - /// Returns an `Identity` defined as the given `bytes` byte array. + /// Create an `Identity` from a LITTLE-ENDIAN byte array. + /// + /// If you are parsing an `Identity` from a string, you probably want `from_be_byte_array` instead. pub const fn from_byte_array(bytes: [u8; 32]) -> Self { - // SAFETY: The transmute is an implementation of `u256::from_ne_bytes`, + // SAFETY: The transmute is an implementation of `u256::from_le_bytes`, // but works in a const context. Self::from_u256(u256::from_le(unsafe { mem::transmute(bytes) })) } + /// Create an `Identity` from a BIG-ENDIAN byte array. + /// + /// This method is the correct choice if you have converted the bytes of a hexadecimal-formatted `Identity` + /// to a byte array in the following way: + /// ```ignore + /// "0xb0b1b2..." + /// -> + /// [0xb0, 0xb1, 0xb2, ...] + /// ``` + pub const fn from_be_byte_array(bytes: [u8; 32]) -> Self { + // SAFETY: The transmute is an implementation of `u256::from_le_bytes`, + // but works in a const context. + Self::from_u256(u256::from_be(unsafe { mem::transmute(bytes) })) + } + /// Converts `__identity__: u256` to `Identity`. pub const fn from_u256(__identity__: u256) -> Self { Self { __identity__ } @@ -69,6 +99,22 @@ impl Identity { } /// Returns an `Identity` defined as the given byte `slice`. + /// The slice is assumed to be in BIG-ENDIAN format. + /// + /// This method is the correct choice if you have converted the bytes of a hexadecimal-formatted `Identity` + /// to a byte array in the following way: + /// ```ignore + /// "0xb0b1b2..." + /// -> + /// [0xb0, 0xb1, 0xb2, ...] + /// ``` + pub fn from_be_slice(slice: &[u8]) -> Self { + Self::from_be_byte_array(slice.try_into().unwrap()) + } + + /// Returns an `Identity` defined as the given byte `slice`. + /// The slice is assumed to be in LITTLE-ENDIAN format. + /// If you are parsing an `Identity` from a string, you probably want `from_be_slice` instead. pub fn from_slice(slice: &[u8]) -> Self { Self::from_byte_array(slice.try_into().unwrap()) } @@ -94,7 +140,11 @@ impl Identity { final_bytes[1] = 0x00; final_bytes[2..6].copy_from_slice(&checksum_hash.as_bytes()[..4]); final_bytes[6..].copy_from_slice(id_hash); - Identity::from_byte_array(final_bytes) + + // We want the leading two bytes of the Identity to be `c200` when formatted. + // This means that these should be the MOST significant bytes. + // This corresponds to a BIG-ENDIAN byte order of our buffer above. + Identity::from_be_byte_array(final_bytes) } /// Returns this `Identity` as a byte array. @@ -102,14 +152,23 @@ impl Identity { self.__identity__.to_le_bytes() } + /// Convert this `Identity` to a BIG-ENDIAN byte array. + pub fn to_be_byte_array(&self) -> [u8; 32] { + self.__identity__.to_be_bytes() + } + + /// Convert this `Identity` to a hexadecimal string. pub fn to_hex(&self) -> HexString<32> { - spacetimedb_sats::hex::encode(&self.to_byte_array()) + spacetimedb_sats::hex::encode(&self.to_be_byte_array()) } + /// Extract the first 8 bytes of this `Identity` as if it was stored in BIG-ENDIAN + /// format. (That is, the most significant bytes.) pub fn abbreviate(&self) -> [u8; 8] { - self.to_byte_array()[..8].try_into().unwrap() + self.to_be_byte_array()[..8].try_into().unwrap() } + /// Extract the first 16 characters of this `Identity`'s hexadecimal representation. pub fn to_abbreviated_hex(&self) -> HexString<8> { spacetimedb_sats::hex::encode(&self.abbreviate()) } @@ -139,7 +198,7 @@ impl hex::FromHex for Identity { type Error = hex::FromHexError; fn from_hex>(hex: T) -> Result { - from_hex_pad(hex).map(Identity::from_byte_array) + from_hex_pad(hex).map(Identity::from_be_byte_array) } } @@ -160,7 +219,7 @@ impl From for AlgebraicValue { #[cfg(feature = "serde")] impl serde::Serialize for Identity { fn serialize(&self, serializer: S) -> Result { - spacetimedb_sats::ser::serde::serialize_to(&self.to_byte_array(), serializer) + spacetimedb_sats::ser::serde::serialize_to(&self.to_be_byte_array(), serializer) } } @@ -168,17 +227,67 @@ impl serde::Serialize for Identity { impl<'de> serde::Deserialize<'de> for Identity { fn deserialize>(deserializer: D) -> Result { let arr = spacetimedb_sats::de::serde::deserialize_from(deserializer)?; - Ok(Identity::from_byte_array(arr)) + Ok(Identity::from_be_byte_array(arr)) } } #[cfg(test)] mod tests { use super::*; - use spacetimedb_sats::GroundSpacetimeType as _; + use proptest::prelude::*; + use proptest::string::string_regex; + use spacetimedb_sats::{de::serde::DeserializeWrapper, ser::serde::SerializeWrapper, GroundSpacetimeType as _}; #[test] fn identity_is_special() { assert!(Identity::get_type().is_special()); } + + #[test] + fn identity_json_serialization_big_endian() { + let id = Identity::from_be_byte_array([ + 0xff, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, + ]); + + let hex = id.to_hex(); + assert!( + hex.as_str().starts_with("ff01"), + "expected {hex:?} to start with \"ff01\"" + ); + + let json1 = serde_json::to_string(&id).unwrap(); + let json2 = serde_json::to_string(SerializeWrapper::from_ref(&id)).unwrap(); + + assert!( + json1.contains(hex.as_str()), + "expected {json1} to contain {hex} but it didn't" + ); + assert!( + json2.contains(hex.as_str()), + "expected {json2} to contain {hex} but it didn't" + ); + } + + proptest! { + #[test] + fn identity_conversions(w0: u128, w1: u128) { + let v = Identity::from_u256(u256::from_words(w0, w1)); + + prop_assert_eq!(Identity::from_byte_array(v.to_byte_array()), v); + prop_assert_eq!(Identity::from_be_byte_array(v.to_be_byte_array()), v); + prop_assert_eq!(Identity::from_hex(v.to_hex()).unwrap(), v); + + let de1: Identity = serde_json::from_str(&serde_json::to_string(&v).unwrap()).unwrap(); + prop_assert_eq!(de1, v); + let DeserializeWrapper(de2): DeserializeWrapper = serde_json::from_str(&serde_json::to_string(SerializeWrapper::from_ref(&v)).unwrap()).unwrap(); + prop_assert_eq!(de2, v); + } + + #[test] + fn from_claims_formats_correctly(s1 in string_regex(r".{3,5}").unwrap(), s2 in string_regex(r".{3,5}").unwrap()) { + let id = Identity::from_claims(&s1, &s2); + prop_assert!(id.to_hex().starts_with("c200")); + } + } } diff --git a/crates/sdk/Cargo.toml b/crates/sdk/Cargo.toml index 59745b4caa7..02fa16b882f 100644 --- a/crates/sdk/Cargo.toml +++ b/crates/sdk/Cargo.toml @@ -22,7 +22,6 @@ futures.workspace = true futures-channel.workspace = true home.workspace = true http.workspace = true -im.workspace = true log.workspace = true rand.workspace = true tokio.workspace = true diff --git a/crates/sdk/examples/quickstart-chat/module_bindings/identity_connected_reducer.rs b/crates/sdk/examples/quickstart-chat/module_bindings/identity_connected_reducer.rs index f15e0b3f320..fafba96a97b 100644 --- a/crates/sdk/examples/quickstart-chat/module_bindings/identity_connected_reducer.rs +++ b/crates/sdk/examples/quickstart-chat/module_bindings/identity_connected_reducer.rs @@ -2,21 +2,26 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct IdentityConnected {} +pub(super) struct IdentityConnectedArgs {} -impl __sdk::spacetime_module::InModule for IdentityConnected { +impl From for super::Reducer { + fn from(args: IdentityConnectedArgs) -> Self { + Self::IdentityConnected + } +} + +impl __sdk::InModule for IdentityConnectedArgs { type Module = super::RemoteModule; } -pub struct IdentityConnectedCallbackId(__sdk::callbacks::CallbackId); +pub struct IdentityConnectedCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `__identity_connected__`. @@ -50,20 +55,33 @@ pub trait identity_connected { impl identity_connected for super::RemoteReducers { fn identity_connected(&self) -> __anyhow::Result<()> { - self.imp.call_reducer("__identity_connected__", IdentityConnected {}) + self.imp + .call_reducer("__identity_connected__", IdentityConnectedArgs {}) } fn on_identity_connected( &self, mut callback: impl FnMut(&super::EventContext) + Send + 'static, ) -> IdentityConnectedCallbackId { - IdentityConnectedCallbackId(self.imp.on_reducer::( + IdentityConnectedCallbackId(self.imp.on_reducer( "__identity_connected__", - Box::new(move |ctx: &super::EventContext, args: &IdentityConnected| callback(ctx)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::IdentityConnected {}, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx) + }), )) } fn remove_on_identity_connected(&self, callback: IdentityConnectedCallbackId) { - self.imp - .remove_on_reducer::("__identity_connected__", callback.0) + self.imp.remove_on_reducer("__identity_connected__", callback.0) } } diff --git a/crates/sdk/examples/quickstart-chat/module_bindings/identity_disconnected_reducer.rs b/crates/sdk/examples/quickstart-chat/module_bindings/identity_disconnected_reducer.rs index 539ad0ecd03..0f48475e772 100644 --- a/crates/sdk/examples/quickstart-chat/module_bindings/identity_disconnected_reducer.rs +++ b/crates/sdk/examples/quickstart-chat/module_bindings/identity_disconnected_reducer.rs @@ -2,21 +2,26 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct IdentityDisconnected {} +pub(super) struct IdentityDisconnectedArgs {} -impl __sdk::spacetime_module::InModule for IdentityDisconnected { +impl From for super::Reducer { + fn from(args: IdentityDisconnectedArgs) -> Self { + Self::IdentityDisconnected + } +} + +impl __sdk::InModule for IdentityDisconnectedArgs { type Module = super::RemoteModule; } -pub struct IdentityDisconnectedCallbackId(__sdk::callbacks::CallbackId); +pub struct IdentityDisconnectedCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `__identity_disconnected__`. @@ -51,20 +56,32 @@ pub trait identity_disconnected { impl identity_disconnected for super::RemoteReducers { fn identity_disconnected(&self) -> __anyhow::Result<()> { self.imp - .call_reducer("__identity_disconnected__", IdentityDisconnected {}) + .call_reducer("__identity_disconnected__", IdentityDisconnectedArgs {}) } fn on_identity_disconnected( &self, mut callback: impl FnMut(&super::EventContext) + Send + 'static, ) -> IdentityDisconnectedCallbackId { - IdentityDisconnectedCallbackId(self.imp.on_reducer::( + IdentityDisconnectedCallbackId(self.imp.on_reducer( "__identity_disconnected__", - Box::new(move |ctx: &super::EventContext, args: &IdentityDisconnected| callback(ctx)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::IdentityDisconnected {}, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx) + }), )) } fn remove_on_identity_disconnected(&self, callback: IdentityDisconnectedCallbackId) { - self.imp - .remove_on_reducer::("__identity_disconnected__", callback.0) + self.imp.remove_on_reducer("__identity_disconnected__", callback.0) } } diff --git a/crates/sdk/examples/quickstart-chat/module_bindings/init_reducer.rs b/crates/sdk/examples/quickstart-chat/module_bindings/init_reducer.rs index ad2fbd48811..50081594cf0 100644 --- a/crates/sdk/examples/quickstart-chat/module_bindings/init_reducer.rs +++ b/crates/sdk/examples/quickstart-chat/module_bindings/init_reducer.rs @@ -2,21 +2,26 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct Init {} +pub(super) struct InitArgs {} -impl __sdk::spacetime_module::InModule for Init { +impl From for super::Reducer { + fn from(args: InitArgs) -> Self { + Self::Init + } +} + +impl __sdk::InModule for InitArgs { type Module = super::RemoteModule; } -pub struct InitCallbackId(__sdk::callbacks::CallbackId); +pub struct InitCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `__init__`. @@ -47,16 +52,29 @@ pub trait init { impl init for super::RemoteReducers { fn init(&self) -> __anyhow::Result<()> { - self.imp.call_reducer("__init__", Init {}) + self.imp.call_reducer("__init__", InitArgs {}) } fn on_init(&self, mut callback: impl FnMut(&super::EventContext) + Send + 'static) -> InitCallbackId { - InitCallbackId(self.imp.on_reducer::( + InitCallbackId(self.imp.on_reducer( "__init__", - Box::new(move |ctx: &super::EventContext, args: &Init| callback(ctx)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::Init {}, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx) + }), )) } fn remove_on_init(&self, callback: InitCallbackId) { - self.imp.remove_on_reducer::("__init__", callback.0) + self.imp.remove_on_reducer("__init__", callback.0) } } diff --git a/crates/sdk/examples/quickstart-chat/module_bindings/message_table.rs b/crates/sdk/examples/quickstart-chat/module_bindings/message_table.rs index 8ecce648cc9..f6cee574100 100644 --- a/crates/sdk/examples/quickstart-chat/module_bindings/message_table.rs +++ b/crates/sdk/examples/quickstart-chat/module_bindings/message_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::message_type::Message; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `message`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.message().on_insert(...)`. pub struct MessageTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl MessageTableAccess for super::RemoteTables { } } -pub struct MessageInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct MessageDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct MessageInsertCallbackId(__sdk::CallbackId); +pub struct MessageDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for MessageTableHandle<'ctx> { +impl<'ctx> __sdk::Table for MessageTableHandle<'ctx> { type Row = Message; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for MessageTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("message"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"message\"") } diff --git a/crates/sdk/examples/quickstart-chat/module_bindings/message_type.rs b/crates/sdk/examples/quickstart-chat/module_bindings/message_type.rs index a015b5780d9..f6827ec2981 100644 --- a/crates/sdk/examples/quickstart-chat/module_bindings/message_type.rs +++ b/crates/sdk/examples/quickstart-chat/module_bindings/message_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -16,6 +15,6 @@ pub struct Message { pub text: String, } -impl __sdk::spacetime_module::InModule for Message { +impl __sdk::InModule for Message { type Module = super::RemoteModule; } diff --git a/crates/sdk/examples/quickstart-chat/module_bindings/mod.rs b/crates/sdk/examples/quickstart-chat/module_bindings/mod.rs index 89acab0f991..dba79d38c0f 100644 --- a/crates/sdk/examples/quickstart-chat/module_bindings/mod.rs +++ b/crates/sdk/examples/quickstart-chat/module_bindings/mod.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; pub mod identity_connected_reducer; @@ -18,18 +17,21 @@ pub mod set_name_reducer; pub mod user_table; pub mod user_type; -pub use identity_connected_reducer::*; -pub use identity_disconnected_reducer::*; -pub use init_reducer::*; +pub use identity_connected_reducer::{ + identity_connected, set_flags_for_identity_connected, IdentityConnectedCallbackId, +}; +pub use identity_disconnected_reducer::{ + identity_disconnected, set_flags_for_identity_disconnected, IdentityDisconnectedCallbackId, +}; +pub use init_reducer::{init, set_flags_for_init, InitCallbackId}; pub use message_table::*; -pub use message_type::*; -pub use send_message_reducer::*; -pub use set_name_reducer::*; +pub use message_type::Message; +pub use send_message_reducer::{send_message, set_flags_for_send_message, SendMessageCallbackId}; +pub use set_name_reducer::{set_flags_for_set_name, set_name, SetNameCallbackId}; pub use user_table::*; -pub use user_type::*; +pub use user_type::User; -#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] -#[sats(crate = __lib)] +#[derive(Clone, PartialEq, Debug)] /// One of the reducers defined by this module. /// @@ -37,34 +39,25 @@ pub use user_type::*; /// to indicate which reducer caused the event. pub enum Reducer { - IdentityConnected(identity_connected_reducer::IdentityConnected), - IdentityDisconnected(identity_disconnected_reducer::IdentityDisconnected), - Init(init_reducer::Init), - SendMessage(send_message_reducer::SendMessage), - SetName(set_name_reducer::SetName), + IdentityConnected, + IdentityDisconnected, + Init, + SendMessage { text: String }, + SetName { name: String }, } -impl __sdk::spacetime_module::InModule for Reducer { +impl __sdk::InModule for Reducer { type Module = RemoteModule; } -impl __sdk::spacetime_module::Reducer for Reducer { +impl __sdk::Reducer for Reducer { fn reducer_name(&self) -> &'static str { match self { - Reducer::IdentityConnected(_) => "__identity_connected__", - Reducer::IdentityDisconnected(_) => "__identity_disconnected__", - Reducer::Init(_) => "__init__", - Reducer::SendMessage(_) => "send_message", - Reducer::SetName(_) => "set_name", - } - } - fn reducer_args(&self) -> &dyn std::any::Any { - match self { - Reducer::IdentityConnected(args) => args, - Reducer::IdentityDisconnected(args) => args, - Reducer::Init(args) => args, - Reducer::SendMessage(args) => args, - Reducer::SetName(args) => args, + Reducer::IdentityConnected => "__identity_connected__", + Reducer::IdentityDisconnected => "__identity_disconnected__", + Reducer::Init => "__init__", + Reducer::SendMessage { .. } => "send_message", + Reducer::SetName { .. } => "set_name", } } } @@ -72,25 +65,23 @@ impl TryFrom<__ws::ReducerCallInfo<__ws::BsatnFormat>> for Reducer { type Error = __anyhow::Error; fn try_from(value: __ws::ReducerCallInfo<__ws::BsatnFormat>) -> __anyhow::Result { match &value.reducer_name[..] { - "__identity_connected__" => Ok(Reducer::IdentityConnected(__sdk::spacetime_module::parse_reducer_args( - "__identity_connected__", - &value.args, - )?)), - "__identity_disconnected__" => Ok(Reducer::IdentityDisconnected( - __sdk::spacetime_module::parse_reducer_args("__identity_disconnected__", &value.args)?, - )), - "__init__" => Ok(Reducer::Init(__sdk::spacetime_module::parse_reducer_args( - "__init__", - &value.args, - )?)), - "send_message" => Ok(Reducer::SendMessage(__sdk::spacetime_module::parse_reducer_args( + "__identity_connected__" => Ok(__sdk::parse_reducer_args::< + identity_connected_reducer::IdentityConnectedArgs, + >("__identity_connected__", &value.args)? + .into()), + "__identity_disconnected__" => Ok(__sdk::parse_reducer_args::< + identity_disconnected_reducer::IdentityDisconnectedArgs, + >("__identity_disconnected__", &value.args)? + .into()), + "__init__" => Ok(__sdk::parse_reducer_args::("__init__", &value.args)?.into()), + "send_message" => Ok(__sdk::parse_reducer_args::( "send_message", &value.args, - )?)), - "set_name" => Ok(Reducer::SetName(__sdk::spacetime_module::parse_reducer_args( - "set_name", - &value.args, - )?)), + )? + .into()), + "set_name" => { + Ok(__sdk::parse_reducer_args::("set_name", &value.args)?.into()) + } _ => Err(__anyhow::anyhow!("Unknown reducer {:?}", value.reducer_name)), } } @@ -100,8 +91,8 @@ impl TryFrom<__ws::ReducerCallInfo<__ws::BsatnFormat>> for Reducer { #[allow(non_snake_case)] #[doc(hidden)] pub struct DbUpdate { - message: __sdk::spacetime_module::TableUpdate, - user: __sdk::spacetime_module::TableUpdate, + message: __sdk::TableUpdate, + user: __sdk::TableUpdate, } impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate { @@ -120,16 +111,16 @@ impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate { } } -impl __sdk::spacetime_module::InModule for DbUpdate { +impl __sdk::InModule for DbUpdate { type Module = RemoteModule; } -impl __sdk::spacetime_module::DbUpdate for DbUpdate { - fn apply_to_client_cache(&self, cache: &mut __sdk::client_cache::ClientCache) { +impl __sdk::DbUpdate for DbUpdate { + fn apply_to_client_cache(&self, cache: &mut __sdk::ClientCache) { cache.apply_diff_to_table::("message", &self.message); cache.apply_diff_to_table::("user", &self.user); } - fn invoke_row_callbacks(&self, event: &EventContext, callbacks: &mut __sdk::callbacks::DbCallbacks) { + fn invoke_row_callbacks(&self, event: &EventContext, callbacks: &mut __sdk::DbCallbacks) { callbacks.invoke_table_row_callbacks::("message", &self.message, event); callbacks.invoke_table_row_callbacks::("user", &self.user, event); } @@ -138,28 +129,17 @@ impl __sdk::spacetime_module::DbUpdate for DbUpdate { #[doc(hidden)] pub struct RemoteModule; -impl __sdk::spacetime_module::InModule for RemoteModule { +impl __sdk::InModule for RemoteModule { type Module = Self; } -impl __sdk::spacetime_module::SpacetimeModule for RemoteModule { - type DbConnection = DbConnection; - type EventContext = EventContext; - type Reducer = Reducer; - type DbView = RemoteTables; - type Reducers = RemoteReducers; - type SetReducerFlags = SetReducerFlags; - type DbUpdate = DbUpdate; - type SubscriptionHandle = SubscriptionHandle; -} - /// The `reducers` field of [`EventContext`] and [`DbConnection`], /// with methods provided by extension traits for each reducer defined by the module. pub struct RemoteReducers { - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for RemoteReducers { +impl __sdk::InModule for RemoteReducers { type Module = RemoteModule; } @@ -170,20 +150,20 @@ impl __sdk::spacetime_module::InModule for RemoteReducers { /// /// This type is currently unstable and may be removed without a major version bump. pub struct SetReducerFlags { - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for SetReducerFlags { +impl __sdk::InModule for SetReducerFlags { type Module = RemoteModule; } /// The `db` field of [`EventContext`] and [`DbConnection`], /// with methods provided by extension traits for each table defined by the module. pub struct RemoteTables { - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for RemoteTables { +impl __sdk::InModule for RemoteTables { type Module = RemoteModule; } @@ -215,14 +195,14 @@ pub struct DbConnection { /// This type is currently unstable and may be removed without a major version bump. pub set_reducer_flags: SetReducerFlags, - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for DbConnection { +impl __sdk::InModule for DbConnection { type Module = RemoteModule; } -impl __sdk::db_context::DbContext for DbConnection { +impl __sdk::DbContext for DbConnection { type DbView = RemoteTables; type Reducers = RemoteReducers; type SetReducerFlags = SetReducerFlags; @@ -245,10 +225,10 @@ impl __sdk::db_context::DbContext for DbConnection { self.imp.disconnect() } - type SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder; + type SubscriptionBuilder = __sdk::SubscriptionBuilder; fn subscription_builder(&self) -> Self::SubscriptionBuilder { - __sdk::subscription::SubscriptionBuilder::new(&self.imp) + __sdk::SubscriptionBuilder::new(&self.imp) } fn try_identity(&self) -> Option<__sdk::Identity> { @@ -264,7 +244,7 @@ impl DbConnection { /// /// See [`__sdk::DbConnectionBuilder`] for required and optional configuration for the new connection. pub fn builder() -> __sdk::DbConnectionBuilder { - __sdk::db_connection::DbConnectionBuilder::new() + __sdk::DbConnectionBuilder::new() } /// If any WebSocket messages are waiting, process one of them. @@ -330,8 +310,8 @@ impl DbConnection { } } -impl __sdk::spacetime_module::DbConnection for DbConnection { - fn new(imp: __sdk::db_connection::DbContextImpl) -> Self { +impl __sdk::DbConnection for DbConnection { + fn new(imp: __sdk::DbContextImpl) -> Self { Self { db: RemoteTables { imp: imp.clone() }, reducers: RemoteReducers { imp: imp.clone() }, @@ -354,15 +334,15 @@ pub struct EventContext { /// This type is currently unstable and may be removed without a major version bump. pub set_reducer_flags: SetReducerFlags, /// The event which caused these callbacks to run. - pub event: __sdk::event::Event, - imp: __sdk::db_connection::DbContextImpl, + pub event: __sdk::Event, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for EventContext { +impl __sdk::InModule for EventContext { type Module = RemoteModule; } -impl __sdk::db_context::DbContext for EventContext { +impl __sdk::DbContext for EventContext { type DbView = RemoteTables; type Reducers = RemoteReducers; type SetReducerFlags = SetReducerFlags; @@ -381,14 +361,14 @@ impl __sdk::db_context::DbContext for EventContext { self.imp.is_active() } - fn disconnect(&self) -> spacetimedb_sdk::anyhow::Result<()> { + fn disconnect(&self) -> __anyhow::Result<()> { self.imp.disconnect() } - type SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder; + type SubscriptionBuilder = __sdk::SubscriptionBuilder; fn subscription_builder(&self) -> Self::SubscriptionBuilder { - __sdk::subscription::SubscriptionBuilder::new(&self.imp) + __sdk::SubscriptionBuilder::new(&self.imp) } fn try_identity(&self) -> Option<__sdk::Identity> { @@ -399,11 +379,11 @@ impl __sdk::db_context::DbContext for EventContext { } } -impl __sdk::spacetime_module::EventContext for EventContext { - fn event(&self) -> &__sdk::event::Event { +impl __sdk::EventContext for EventContext { + fn event(&self) -> &__sdk::Event { &self.event } - fn new(imp: __sdk::db_connection::DbContextImpl, event: __sdk::event::Event) -> Self { + fn new(imp: __sdk::DbContextImpl, event: __sdk::Event) -> Self { Self { db: RemoteTables { imp: imp.clone() }, reducers: RemoteReducers { imp: imp.clone() }, @@ -417,15 +397,15 @@ impl __sdk::spacetime_module::EventContext for EventContext { /// A handle on a subscribed query. // TODO: Document this better after implementing the new subscription API. pub struct SubscriptionHandle { - imp: __sdk::subscription::SubscriptionHandleImpl, + imp: __sdk::SubscriptionHandleImpl, } -impl __sdk::spacetime_module::InModule for SubscriptionHandle { +impl __sdk::InModule for SubscriptionHandle { type Module = RemoteModule; } -impl __sdk::spacetime_module::SubscriptionHandle for SubscriptionHandle { - fn new(imp: __sdk::subscription::SubscriptionHandleImpl) -> Self { +impl __sdk::SubscriptionHandle for SubscriptionHandle { + fn new(imp: __sdk::SubscriptionHandleImpl) -> Self { Self { imp } } } @@ -440,7 +420,7 @@ pub trait RemoteDbContext: DbView = RemoteTables, Reducers = RemoteReducers, SetReducerFlags = SetReducerFlags, - SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder, + SubscriptionBuilder = __sdk::SubscriptionBuilder, > { } @@ -449,8 +429,24 @@ impl< DbView = RemoteTables, Reducers = RemoteReducers, SetReducerFlags = SetReducerFlags, - SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder, + SubscriptionBuilder = __sdk::SubscriptionBuilder, >, > RemoteDbContext for Ctx { } + +impl __sdk::SpacetimeModule for RemoteModule { + type DbConnection = DbConnection; + type EventContext = EventContext; + type Reducer = Reducer; + type DbView = RemoteTables; + type Reducers = RemoteReducers; + type SetReducerFlags = SetReducerFlags; + type DbUpdate = DbUpdate; + type SubscriptionHandle = SubscriptionHandle; + + fn register_tables(client_cache: &mut __sdk::ClientCache) { + message_table::register_table(client_cache); + user_table::register_table(client_cache); + } +} diff --git a/crates/sdk/examples/quickstart-chat/module_bindings/send_message_reducer.rs b/crates/sdk/examples/quickstart-chat/module_bindings/send_message_reducer.rs index 70627bd06e2..092afad3a84 100644 --- a/crates/sdk/examples/quickstart-chat/module_bindings/send_message_reducer.rs +++ b/crates/sdk/examples/quickstart-chat/module_bindings/send_message_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct SendMessage { +pub(super) struct SendMessageArgs { pub text: String, } -impl __sdk::spacetime_module::InModule for SendMessage { +impl From for super::Reducer { + fn from(args: SendMessageArgs) -> Self { + Self::SendMessage { text: args.text } + } +} + +impl __sdk::InModule for SendMessageArgs { type Module = super::RemoteModule; } -pub struct SendMessageCallbackId(__sdk::callbacks::CallbackId); +pub struct SendMessageCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `send_message`. @@ -52,19 +57,32 @@ pub trait send_message { impl send_message for super::RemoteReducers { fn send_message(&self, text: String) -> __anyhow::Result<()> { - self.imp.call_reducer("send_message", SendMessage { text }) + self.imp.call_reducer("send_message", SendMessageArgs { text }) } fn on_send_message( &self, mut callback: impl FnMut(&super::EventContext, &String) + Send + 'static, ) -> SendMessageCallbackId { - SendMessageCallbackId(self.imp.on_reducer::( + SendMessageCallbackId(self.imp.on_reducer( "send_message", - Box::new(move |ctx: &super::EventContext, args: &SendMessage| callback(ctx, &args.text)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::SendMessage { text }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, text) + }), )) } fn remove_on_send_message(&self, callback: SendMessageCallbackId) { - self.imp.remove_on_reducer::("send_message", callback.0) + self.imp.remove_on_reducer("send_message", callback.0) } } diff --git a/crates/sdk/examples/quickstart-chat/module_bindings/set_name_reducer.rs b/crates/sdk/examples/quickstart-chat/module_bindings/set_name_reducer.rs index aed78b363b2..f195ee29141 100644 --- a/crates/sdk/examples/quickstart-chat/module_bindings/set_name_reducer.rs +++ b/crates/sdk/examples/quickstart-chat/module_bindings/set_name_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct SetName { +pub(super) struct SetNameArgs { pub name: String, } -impl __sdk::spacetime_module::InModule for SetName { +impl From for super::Reducer { + fn from(args: SetNameArgs) -> Self { + Self::SetName { name: args.name } + } +} + +impl __sdk::InModule for SetNameArgs { type Module = super::RemoteModule; } -pub struct SetNameCallbackId(__sdk::callbacks::CallbackId); +pub struct SetNameCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `set_name`. @@ -49,19 +54,32 @@ pub trait set_name { impl set_name for super::RemoteReducers { fn set_name(&self, name: String) -> __anyhow::Result<()> { - self.imp.call_reducer("set_name", SetName { name }) + self.imp.call_reducer("set_name", SetNameArgs { name }) } fn on_set_name( &self, mut callback: impl FnMut(&super::EventContext, &String) + Send + 'static, ) -> SetNameCallbackId { - SetNameCallbackId(self.imp.on_reducer::( + SetNameCallbackId(self.imp.on_reducer( "set_name", - Box::new(move |ctx: &super::EventContext, args: &SetName| callback(ctx, &args.name)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::SetName { name }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, name) + }), )) } fn remove_on_set_name(&self, callback: SetNameCallbackId) { - self.imp.remove_on_reducer::("set_name", callback.0) + self.imp.remove_on_reducer("set_name", callback.0) } } diff --git a/crates/sdk/examples/quickstart-chat/module_bindings/user_table.rs b/crates/sdk/examples/quickstart-chat/module_bindings/user_table.rs index 5809e27a6af..d0396024c2c 100644 --- a/crates/sdk/examples/quickstart-chat/module_bindings/user_table.rs +++ b/crates/sdk/examples/quickstart-chat/module_bindings/user_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::user_type::User; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `user`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.user().on_insert(...)`. pub struct UserTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UserTableAccess for super::RemoteTables { } } -pub struct UserInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UserDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UserInsertCallbackId(__sdk::CallbackId); +pub struct UserDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UserTableHandle<'ctx> { +impl<'ctx> __sdk::Table for UserTableHandle<'ctx> { type Row = User; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for UserTableHandle<'ctx> { } } -pub struct UserUpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("user"); + _table.add_unique_constraint::<__sdk::Identity>("identity", |row| &row.identity); +} +pub struct UserUpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for UserTableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for UserTableHandle<'ctx> { type UpdateCallbackId = UserUpdateCallbackId; fn on_update( @@ -102,12 +106,9 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for UserTableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::<__sdk::Identity>( - raw_updates, - |row: &User| &row.identity, - ) - .context("Failed to parse table update for table \"user\"") +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::<__sdk::Identity>(raw_updates, |row: &User| &row.identity) + .context("Failed to parse table update for table \"user\"") } /// Access to the `identity` unique index on the table `user`, @@ -118,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.user().identity().find(...)`. pub struct UserIdentityUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -126,9 +127,7 @@ impl<'ctx> UserTableHandle<'ctx> { /// Get a handle on the `identity` unique index on the table `user`. pub fn identity(&self) -> UserIdentityUnique<'ctx> { UserIdentityUnique { - imp: self - .imp - .get_unique_constraint::<__sdk::Identity>("identity", |row| &row.identity), + imp: self.imp.get_unique_constraint::<__sdk::Identity>("identity"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/examples/quickstart-chat/module_bindings/user_type.rs b/crates/sdk/examples/quickstart-chat/module_bindings/user_type.rs index 2194e5de5b6..b3e30cbab5e 100644 --- a/crates/sdk/examples/quickstart-chat/module_bindings/user_type.rs +++ b/crates/sdk/examples/quickstart-chat/module_bindings/user_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -16,6 +15,6 @@ pub struct User { pub online: bool, } -impl __sdk::spacetime_module::InModule for User { +impl __sdk::InModule for User { type Module = super::RemoteModule; } diff --git a/crates/sdk/src/callbacks.rs b/crates/sdk/src/callbacks.rs index 13e55eb1c1a..01175af130f 100644 --- a/crates/sdk/src/callbacks.rs +++ b/crates/sdk/src/callbacks.rs @@ -201,10 +201,10 @@ impl TableCallbacks { /// A reducer callback for a reducer defined by the module `M`. /// -/// Reducer arguments are passed to callbacks as `&dyn Any` to the argument product, -/// and a wrapper inserted by the SDK will downcast and unpack the arguments +/// Reducer arguments are passed to callbacks within the `EventContext`, +/// and a wrapper inserted by the SDK will destructure the contained `Event` /// before invoking the user-supplied function. -pub(crate) type ReducerCallback = Box::EventContext, &dyn Any) + Send + 'static>; +pub(crate) type ReducerCallback = Box::EventContext) + Send + 'static>; type ReducerCallbackMap = HashMap>; @@ -228,10 +228,9 @@ impl Default for ReducerCallbacks { impl ReducerCallbacks { pub(crate) fn invoke_on_reducer(&mut self, ctx: &M::EventContext, reducer: &M::Reducer) { let name = reducer.reducer_name(); - let args = reducer.reducer_args(); if let Some(callbacks) = self.callbacks.get_mut(name) { for callback in callbacks.values_mut() { - callback(ctx, args); + callback(ctx); } } } diff --git a/crates/sdk/src/client_cache.rs b/crates/sdk/src/client_cache.rs index ab4228f345e..8145636dbef 100644 --- a/crates/sdk/src/client_cache.rs +++ b/crates/sdk/src/client_cache.rs @@ -7,15 +7,17 @@ //! //! This module is internal, and may incompatibly change without warning. +use crate::callbacks::CallbackId; +use crate::db_connection::{PendingMutation, SharedCell}; use crate::spacetime_module::{InModule, SpacetimeModule, TableUpdate}; -use anymap::{any::CloneAny, Map}; +use anymap::{any::Any, Map}; use bytes::Bytes; -use im::HashMap; +use futures_channel::mpsc; +use std::collections::HashMap; use std::marker::PhantomData; use std::sync::Arc; /// A local mirror of the subscribed rows of one table in the database. -#[derive(Clone)] pub struct TableCache { /// A map of row-bytes to rows. /// @@ -26,9 +28,16 @@ pub struct TableCache { /// are more efficient than for domain types, /// as they can be implemented directly via SIMD without skipping padding /// or branching on enum variants. - /// - /// Note that this is an [`im::HashMap`], and so can be shared efficiently. pub(crate) entries: HashMap, + + /// Each of the unique indices on this table. + /// + /// The values of this map will all be instances of `UniqueIndexImpl`. + /// The boxing and `dyn` dispatch is necessary to erase the type of the indexed column. + /// + /// Entries are added to this map during [`crate::DbConnectionBuilder::build`], + /// via a `register_table` function autogenerated for each table. + pub(crate) unique_indices: HashMap<&'static str, Box>>, } // Can't derive this because the `Row` generic messes us up. @@ -36,51 +45,88 @@ impl Default for TableCache { fn default() -> Self { Self { entries: Default::default(), + unique_indices: Default::default(), } } } -impl TableCache { +impl TableCache { /// Apply all the deletes, inserts and updates recorded in `diff`. - pub fn apply_diff(&mut self, diff: &TableUpdate) { + fn apply_diff(&mut self, diff: &TableUpdate) { // Apply deletes strictly before inserts, - // to avoid needlessly growing the `entries` map. + // to avoid duplicates in any unique index. for delete in &diff.deletes { self.entries.remove(&delete.bsatn); + for index in self.unique_indices.values_mut() { + index.remove_row(&delete.row); + } } for update in &diff.updates { self.entries.remove(&update.delete.bsatn); + for index in self.unique_indices.values_mut() { + index.remove_row(&update.delete.row); + } } for insert in &diff.inserts { self.entries.insert(insert.bsatn.clone(), insert.row.clone()); + for index in self.unique_indices.values_mut() { + index.add_row(insert.row.clone()); + } } for update in &diff.updates { self.entries .insert(update.insert.bsatn.clone(), update.insert.row.clone()); + for index in self.unique_indices.values_mut() { + index.add_row(update.insert.row.clone()); + } + } + } + + fn find_by_unique_index<'this>( + &'this self, + unique_index_name: &'static str, + key: &'_ dyn std::any::Any, + ) -> Option<&'this Row> { + let index = self + .unique_indices + .get(unique_index_name) + .unwrap_or_else(|| panic!("No such unique index: {unique_index_name}")); + index.find_row(key) + } + + /// Called by the codegen when initializing the client cache during [`crate::DbConnectionBuilder::build`]. + pub fn add_unique_constraint(&mut self, unique_index_name: &'static str, get_unique_col: fn(&Row) -> &Col) + where + Col: Any + Clone + std::hash::Hash + Eq + Send + Sync + std::fmt::Debug + 'static, + { + assert!(self.entries.is_empty(), "Cannot add a unique constraint to a populated table; constraints should only be added during initialization, before subscribing to any rows."); + if self + .unique_indices + .insert( + unique_index_name, + Box::new(UniqueIndexImpl { + get_unique_col, + rows: Default::default(), + }), + ) + .is_some() + { + panic!("Duplicate unique constraint name {unique_index_name}"); } } } /// A local mirror of the subscribed subset of the database. -pub struct ClientCache { - /// "keyed" on the type `HashMap<&'static str, Arc>`. +pub struct ClientCache { + /// "keyed" on the type `HashMap<&'static str, TableCache`. /// /// The strings are table names, since we may have multiple tables with the same row type. - tables: Map, + tables: Map, _module: PhantomData, } -impl Clone for ClientCache { - fn clone(&self) -> Self { - Self { - tables: self.tables.clone(), - _module: PhantomData, - } - } -} - impl Default for ClientCache { fn default() -> Self { Self { @@ -95,12 +141,25 @@ impl ClientCache { pub(crate) fn get_table + Send + Sync + 'static>( &self, table_name: &'static str, - ) -> Option<&Arc>> { + ) -> Option<&TableCache> { self.tables - .get::>>>() + .get::>>() .and_then(|tables_of_row_type| tables_of_row_type.get(table_name)) } + /// Called internally when updating the client cache in response to WebSocket messages, + /// and by the codegen when initializing the client cache during [`crate::DbConnectionBuilder::build`]. + pub fn get_or_make_table + Send + Sync + 'static>( + &mut self, + table_name: &'static str, + ) -> &mut TableCache { + self.tables + .entry::>>() + .or_insert_with(Default::default) + .entry(table_name) + .or_default() + } + /// Apply all the mutations in `diff` /// to the [`TableCache`] which stores rows of type `Row` for the table `table_name`. pub fn apply_diff_to_table + Clone + Send + Sync + 'static>( @@ -112,41 +171,245 @@ impl ClientCache { return; } - // Clippy is incorrect here: `.cloned` will do `Arc::clone`, not `TableCache::clone`. - // TODO: Do we need to be `Arc`ing these? `im::HashMap` should be doing sharing internally anyway. - #[allow(clippy::map_clone)] - let mut table = self - .get_table::(table_name) - .map(|tbl| TableCache::clone(tbl)) - .unwrap_or_default(); + let table = self.get_or_make_table::(table_name); table.apply_diff(diff); - self.tables - .entry::>>>() - .or_insert(HashMap::default()) - .insert(table_name, Arc::new(table)); } } -/// A shared view into a particular state of the `ClientCache`. -pub(crate) type ClientCacheView = Arc>; +/// Internal implementation of a generated `TableHandle` struct, +/// which mediates access to a table in the client cache. +/// +/// `TableHandle`s don't actually hold a direct reference to the table they access, +/// as that would require both gnarly lifetimes and also a `MutexGuard` on the client cache. +/// Instead, they hold an `Arc` on the whole [`ClientCache`], +/// with every operation through the table handle +/// acquiring the lock only for the duration of the operation, +/// calling [`ClientCache::get_table`] and then discarding its reference before returning. +pub struct TableHandle { + pub(crate) client_cache: SharedCell>, + /// Handle on the connection's `pending_mutations_send` channel, + /// so we can send callback-related [`PendingMutation`] messages. + pub(crate) pending_mutations: mpsc::UnboundedSender>, + + /// The name of the table. + pub(crate) table_name: &'static str, +} + +impl Clone for TableHandle { + fn clone(&self) -> Self { + Self { + client_cache: Arc::clone(&self.client_cache), + pending_mutations: self.pending_mutations.clone(), + table_name: self.table_name, + } + } +} + +impl TableHandle { + /// Read something out of the [`TableCache`] which this `TableHandle` accesses. + fn with_table_cache(&self, get: impl FnOnce(&TableCache) -> Res) -> Res { + let client_cache = self.client_cache.lock().unwrap(); + client_cache + .get_table::(self.table_name) + .map(get) + .unwrap_or_else(|| panic!("No such table: {}", self.table_name)) + } + + /// Called by the autogenerated implementation of the [`crate::Table`] method of the same name. + pub fn count(&self) -> u64 { + self.with_table_cache(|table| table.entries.len() as u64) + } + + /// Called by the autogenerated implementation of the [`crate::Table`] method of the same name. + pub fn iter(&self) -> impl Iterator { + self.with_table_cache(|table| table.entries.values().cloned().collect::>()) + .into_iter() + } + + /// See [`DbContextImpl::queue_mutation`]. + fn queue_mutation(&self, mutation: PendingMutation) { + self.pending_mutations.unbounded_send(mutation).unwrap(); + } + + /// Called by the autogenerated implementation of the [`crate::Table`] method of the same name. + pub fn on_insert( + &self, + mut callback: impl FnMut(&::EventContext, &Row) + Send + 'static, + ) -> CallbackId { + let callback_id = CallbackId::get_next(); + self.queue_mutation(PendingMutation::AddInsertCallback { + table: self.table_name, + callback: Box::new(move |ctx, row| { + let row = row.downcast_ref::().unwrap(); + callback(ctx, row); + }), + callback_id, + }); + callback_id + } + + /// Called by the autogenerated implementation of the [`crate::Table`] method of the same name. + pub fn remove_on_insert(&self, callback: CallbackId) { + self.queue_mutation(PendingMutation::RemoveInsertCallback { + table: self.table_name, + callback_id: callback, + }); + } + + /// Called by the autogenerated implementation of the [`crate::Table`] method of the same name. + pub fn on_delete( + &self, + mut callback: impl FnMut(&::EventContext, &Row) + Send + 'static, + ) -> CallbackId { + let callback_id = CallbackId::get_next(); + self.queue_mutation(PendingMutation::AddDeleteCallback { + table: self.table_name, + callback: Box::new(move |ctx, row| { + let row = row.downcast_ref::().unwrap(); + callback(ctx, row); + }), + callback_id, + }); + callback_id + } + + /// Called by the autogenerated implementation of the [`crate::Table`] method of the same name. + pub fn remove_on_delete(&self, callback: CallbackId) { + self.queue_mutation(PendingMutation::RemoveDeleteCallback { + table: self.table_name, + callback_id: callback, + }); + } + + /// Called by the autogenerated implementation of the [`crate::TableWithPrimaryKey`] method of the same name. + pub fn on_update( + &self, + mut callback: impl FnMut(&::EventContext, &Row, &Row) + Send + 'static, + ) -> CallbackId { + let callback_id = CallbackId::get_next(); + self.queue_mutation(PendingMutation::AddUpdateCallback { + table: self.table_name, + callback: Box::new(move |ctx, old, new| { + let old = old.downcast_ref::().unwrap(); + let new = new.downcast_ref::().unwrap(); + callback(ctx, old, new); + }), + callback_id, + }); + callback_id + } + + /// Called by the autogenerated implementation of the [`crate::TableWithPrimaryKey`] method of the same name. + pub fn remove_on_update(&self, callback: CallbackId) { + self.queue_mutation(PendingMutation::RemoveUpdateCallback { + table: self.table_name, + callback_id: callback, + }); + } + + /// Called by autogenerated unique index access methods. + pub fn get_unique_constraint(&self, constraint_name: &'static str) -> UniqueConstraintHandle { + UniqueConstraintHandle { + table_handle: self.clone(), + unique_index_name: constraint_name, + _phantom: PhantomData, + } + } +} /// A fake implementation of a unique index. /// /// This struct should allow efficient point queries of a particular field in the table, /// but our current implementation just does a full scan. -// TODO: Actual client-side indices. -pub struct UniqueConstraint { - pub(crate) get_unique_field: fn(&Row) -> &Col, - pub(crate) table: Arc>, +/// +/// Like [`TableHandle`], unique constraint handles don't hold a direct reference to their table +/// or an index within it. (No such index currently exists, anyways.) +/// Instead, they hold a handle on the whole [`ClientCache`], +/// and acquire short-lived exclusive access to it during operations. +pub struct UniqueConstraintHandle { + table_handle: TableHandle, + unique_index_name: &'static str, + _phantom: PhantomData>, } -impl UniqueConstraint { +impl< + Row: Clone + InModule + Send + Sync + 'static, + Col: std::any::Any + Eq + std::hash::Hash + Clone + Send + Sync + std::fmt::Debug + 'static, + > UniqueConstraintHandle +{ pub fn find(&self, col_val: &Col) -> Option { - self.table - .entries - .values() - .find(|row| (self.get_unique_field)(row) == col_val) - .cloned() + self.table_handle + .with_table_cache(|table| table.find_by_unique_index(self.unique_index_name, col_val).cloned()) + } +} + +/// [`UniqueIndexImpl`], but with its `Col` type parameter erased. +pub trait UniqueIndexDyn: Send + Sync + 'static { + /// The `Row` type parameter to [`UniqueIndexImpl`]; the type of rows in the indexed table. + type Row: Clone + Send + Sync + 'static; + + /// Insert a new row into the index. + /// + /// Panics if an existing row has the same value in the indexed column. + fn add_row(&mut self, row: Self::Row); + /// Delete a row from the index. + /// + /// Panics if no resident row in the index has the same value in the indexed column. + /// + /// Does not check that the row removed from the index is exactly equal to `row`, + /// only that they have matching values in the indexed column. + fn remove_row(&mut self, row: &Self::Row); + /// Look up the row with `key` as its value in the indexed column, + /// if such a row is resident in the client cache. + /// + /// Panics if `key` is not of the same type as the indexed column. + fn find_row<'this>(&'this self, key: &'_ dyn std::any::Any) -> Option<&'this Self::Row>; +} + +/// A unique index on a table with rows of type `Row`, indexing a column of type `Col`. +pub struct UniqueIndexImpl { + /// All the rows in the table, indexed by their unique column. + /// + /// Unpleasant hack: each unique index stores duplicates of the entire row, + /// rather than, say, an index or reference into the containing table. + /// This is because [`HashMap`] does not expose stable indices/references other than hashes, + /// and the chief competitor which does, `IndexMap`, loses index/reference stability + /// when removing elements, which would require complicated fixups. + /// + /// One could imagine storing an `IntMap` from opaque indices/references to rows, + /// having the outer [`TableCache`] map row bytes to these integers, + /// and having unique indices do the same. + rows: HashMap, + /// Given a row, get the value of the indexed column. + get_unique_col: fn(&Row) -> &Col, +} + +impl UniqueIndexDyn for UniqueIndexImpl +where + Row: Clone + Send + Sync + 'static, + Col: Any + Clone + std::hash::Hash + Eq + Send + Sync + std::fmt::Debug + 'static, +{ + type Row = Row; + fn add_row(&mut self, row: Self::Row) { + let col = (self.get_unique_col)(&row).clone(); + if let Some(prev_row) = self.rows.insert(col, row) { + panic!( + "Duplicated entry in unique index at key {:?}", + (self.get_unique_col)(&prev_row) + ); + } + } + fn remove_row(&mut self, row: &Self::Row) { + let col = (self.get_unique_col)(row); + self.rows + .remove(col) + .expect("UniqueIndexDyn::remove_row for non-present row"); + } + fn find_row<'this>(&'this self, key: &'_ dyn std::any::Any) -> Option<&'this Self::Row> { + let col = key + .downcast_ref::() + .expect("UniqueIndexDyn::find_row with key of incorrect type"); + self.rows.get(col) } } diff --git a/crates/sdk/src/db_connection.rs b/crates/sdk/src/db_connection.rs index 4739226d32c..ca9ffdbb289 100644 --- a/crates/sdk/src/db_connection.rs +++ b/crates/sdk/src/db_connection.rs @@ -20,21 +20,22 @@ use crate::{ callbacks::{CallbackId, DbCallbacks, ReducerCallback, ReducerCallbacks, RowCallback, UpdateCallback}, - client_cache::{ClientCache, ClientCacheView, TableCache, UniqueConstraint}, + client_cache::{ClientCache, TableHandle}, spacetime_module::{DbConnection, DbUpdate, EventContext, InModule, SpacetimeModule}, subscription::{OnAppliedCallback, OnErrorCallback, SubscriptionManager}, websocket::{WsConnection, WsParams}, - ws_messages as ws, Event, ReducerEvent, Status, + Event, ReducerEvent, Status, }; use anyhow::{bail, Context, Result}; use bytes::Bytes; use futures::StreamExt; use futures_channel::mpsc; use http::Uri; +use spacetimedb_client_api_messages::websocket as ws; use spacetimedb_client_api_messages::websocket::{BsatnFormat, CallReducerFlags, Compression}; -use spacetimedb_data_structures::map::HashMap; -use spacetimedb_lib::{bsatn, de::Deserialize, ser::Serialize, Address, Identity}; +use spacetimedb_lib::{bsatn, ser::Serialize, Address, Identity}; use std::{ + collections::HashMap, sync::{Arc, Mutex as StdMutex, OnceLock}, time::{Duration, SystemTime}, }; @@ -56,8 +57,8 @@ pub struct DbContextImpl { /// All the state which is safe to hold a lock on while running callbacks. pub(crate) inner: SharedCell>, - /// The most recent client cache state. - cache: SharedCell>, + /// The client cache, which stores subscribed rows. + cache: SharedCell>, /// Receiver channel for WebSocket messages, /// which are pre-parsed in the background by [`parse_loop`]. @@ -136,12 +137,13 @@ impl DbContextImpl { // set the received state to store all the rows, // then invoke the on-applied and row callbacks. ParsedMessage::InitialSubscription { db_update, sub_id } => { - let prev_cache_view = Arc::clone(&*self.cache.lock().unwrap()); - let mut new_cache = ClientCache::clone(&*prev_cache_view); - // FIXME: delete no-longer-subscribed rows. - db_update.apply_to_client_cache(&mut new_cache); - let new_cache_view = Arc::new(new_cache); - *self.cache.lock().unwrap() = new_cache_view; + // Lock the client cache in a restricted scope, + // so that it will be unlocked when callbacks run. + { + let mut cache = self.cache.lock().unwrap(); + // FIXME: delete no-longer-subscribed rows. + db_update.apply_to_client_cache(&mut *cache); + } let event_ctx = self.make_event_ctx(Event::SubscribeApplied); let mut inner = self.inner.lock().unwrap(); inner.subscriptions.subscription_applied(&event_ctx, sub_id); @@ -154,11 +156,12 @@ impl DbContextImpl { // apply the received diff to the client cache, // then invoke on-reducer and row callbacks. ParsedMessage::TransactionUpdate(event, Some(update)) => { - let prev_cache_view = Arc::clone(&*self.cache.lock().unwrap()); - let mut new_cache = ClientCache::clone(&*prev_cache_view); - update.apply_to_client_cache(&mut new_cache); - let new_cache_view = Arc::new(new_cache); - *self.cache.lock().unwrap() = new_cache_view; + // Lock the client cache in a restricted scope, + // so that it will be unlocked when callbacks run. + { + let mut cache = self.cache.lock().unwrap(); + update.apply_to_client_cache(&mut *cache); + } let event_ctx = self.make_event_ctx(event); let mut inner = self.inner.lock().unwrap(); if let Event::Reducer(reducer_event) = event_ctx.event() { @@ -203,7 +206,7 @@ impl DbContextImpl { inner.on_disconnect.take() }; if let Some(disconnect_callback) = disconnected_callback { - let ctx = M::DbConnection::new(self.clone()); + let ctx = ::new(self.clone()); disconnect_callback(&ctx, err); } } @@ -511,18 +514,12 @@ impl DbContextImpl { &self, table_name: &'static str, ) -> TableHandle { - let table_view = self - .cache - .lock() - .unwrap() - .get_table::(table_name) - .cloned() - .unwrap_or_else(|| Arc::new(TableCache::default())); + let client_cache = Arc::clone(&self.cache); let pending_mutations = self.pending_mutations_send.clone(); TableHandle { - table_view, + client_cache, pending_mutations, - table: table_name, + table_name, } } @@ -549,25 +546,18 @@ impl DbContextImpl { } /// Called by autogenerated reducer callback methods. - pub fn on_reducer + InModule + 'static>( - &self, - reducer_name: &'static str, - mut callback: impl FnMut(&M::EventContext, &Args) + Send + 'static, - ) -> CallbackId { + pub fn on_reducer(&self, reducer_name: &'static str, callback: ReducerCallback) -> CallbackId { let callback_id = CallbackId::get_next(); self.queue_mutation(PendingMutation::AddReducerCallback { reducer: reducer_name, callback_id, - callback: Box::new(move |ctx, args| { - let args = args.downcast_ref::().unwrap(); - callback(ctx, args); - }), + callback, }); callback_id } /// Called by autogenerated reducer callback methods. - pub fn remove_on_reducer>(&self, reducer_name: &'static str, callback: CallbackId) { + pub fn remove_on_reducer(&self, reducer_name: &'static str, callback: CallbackId) { self.queue_mutation(PendingMutation::RemoveReducerCallback { reducer: reducer_name, callback_id: callback, @@ -639,124 +629,6 @@ impl CallReducerFlagsMap { } } -/// Internal implementation of a generated `TableHandle` struct, -/// which mediates access to a table in the client cache. -pub struct TableHandle { - /// May be `None` if there are no rows in the table cache. - table_view: Arc>, - /// Handle on the connection's `pending_mutations_send` channel, - /// so we can send callback-related [`PendingMutation`] messages. - pending_mutations: mpsc::UnboundedSender>, - - /// The name of the table. - table: &'static str, -} - -impl TableHandle { - /// Called by the autogenerated implementation of the [`crate::Table`] method of the same name. - pub fn count(&self) -> u64 { - self.table_view.entries.len() as u64 - } - - /// Called by the autogenerated implementation of the [`crate::Table`] method of the same name. - pub fn iter(&self) -> impl Iterator + '_ { - self.table_view.entries.values().cloned() - } - - /// See [`DbContextImpl::queue_mutation`]. - fn queue_mutation(&self, mutation: PendingMutation) { - self.pending_mutations.unbounded_send(mutation).unwrap(); - } - - /// Called by the autogenerated implementation of the [`crate::Table`] method of the same name. - pub fn on_insert( - &self, - mut callback: impl FnMut(&::EventContext, &Row) + Send + 'static, - ) -> CallbackId { - let callback_id = CallbackId::get_next(); - self.queue_mutation(PendingMutation::AddInsertCallback { - table: self.table, - callback: Box::new(move |ctx, row| { - let row = row.downcast_ref::().unwrap(); - callback(ctx, row); - }), - callback_id, - }); - callback_id - } - - /// Called by the autogenerated implementation of the [`crate::Table`] method of the same name. - pub fn remove_on_insert(&self, callback: CallbackId) { - self.queue_mutation(PendingMutation::RemoveInsertCallback { - table: self.table, - callback_id: callback, - }); - } - - /// Called by the autogenerated implementation of the [`crate::Table`] method of the same name. - pub fn on_delete( - &self, - mut callback: impl FnMut(&::EventContext, &Row) + Send + 'static, - ) -> CallbackId { - let callback_id = CallbackId::get_next(); - self.queue_mutation(PendingMutation::AddDeleteCallback { - table: self.table, - callback: Box::new(move |ctx, row| { - let row = row.downcast_ref::().unwrap(); - callback(ctx, row); - }), - callback_id, - }); - callback_id - } - - /// Called by the autogenerated implementation of the [`crate::Table`] method of the same name. - pub fn remove_on_delete(&self, callback: CallbackId) { - self.queue_mutation(PendingMutation::RemoveDeleteCallback { - table: self.table, - callback_id: callback, - }); - } - - /// Called by the autogenerated implementation of the [`crate::TableWithPrimaryKey`] method of the same name. - pub fn on_update( - &self, - mut callback: impl FnMut(&::EventContext, &Row, &Row) + Send + 'static, - ) -> CallbackId { - let callback_id = CallbackId::get_next(); - self.queue_mutation(PendingMutation::AddUpdateCallback { - table: self.table, - callback: Box::new(move |ctx, old, new| { - let old = old.downcast_ref::().unwrap(); - let new = new.downcast_ref::().unwrap(); - callback(ctx, old, new); - }), - callback_id, - }); - callback_id - } - - /// Called by the autogenerated implementation of the [`crate::TableWithPrimaryKey`] method of the same name. - pub fn remove_on_update(&self, callback: CallbackId) { - self.queue_mutation(PendingMutation::RemoveUpdateCallback { - table: self.table, - callback_id: callback, - }); - } - - /// Called by autogenerated unique index access methods. - pub fn get_unique_constraint( - &self, - _constraint_name: &'static str, - get_unique_field: fn(&Row) -> &Col, - ) -> UniqueConstraint { - UniqueConstraint { - table: Arc::clone(&self.table_view), - get_unique_field, - } - } -} - /// A builder-pattern constructor for a `DbConnection` connection to the module `M`. /// /// `M` will be the autogenerated opaque module type. @@ -884,11 +756,16 @@ but you must call one of them, or else the connection will never progress. on_disconnect: self.on_disconnect, call_reducer_flags: <_>::default(), })); + + let mut cache = ClientCache::default(); + M::register_tables(&mut cache); + let cache = Arc::new(StdMutex::new(cache)); + let (pending_mutations_send, pending_mutations_recv) = mpsc::unbounded(); let ctx_imp = DbContextImpl { runtime: handle, inner, - cache: <_>::default(), + cache, recv: Arc::new(TokioMutex::new(parsed_recv_chan)), pending_mutations_send, pending_mutations_recv: Arc::new(TokioMutex::new(pending_mutations_recv)), diff --git a/crates/sdk/src/event.rs b/crates/sdk/src/event.rs index eebd667374e..a3bb18b1c69 100644 --- a/crates/sdk/src/event.rs +++ b/crates/sdk/src/event.rs @@ -11,7 +11,7 @@ //! to determine what change in your connection's state caused the callback to run. use crate::spacetime_module::{DbUpdate as _, SpacetimeModule}; -use spacetimedb_client_api_messages::websocket::BsatnFormat; +use spacetimedb_client_api_messages::websocket as ws; use spacetimedb_lib::{Address, Identity}; use std::time::SystemTime; @@ -99,14 +99,12 @@ pub enum Status { impl Status { pub(crate) fn parse_status_and_update( - status: crate::ws_messages::UpdateStatus, + status: ws::UpdateStatus, ) -> anyhow::Result<(Self, Option)> { Ok(match status { - crate::ws_messages::UpdateStatus::Committed(update) => { - (Self::Committed, Some(M::DbUpdate::parse_update(update)?)) - } - crate::ws_messages::UpdateStatus::Failed(errmsg) => (Self::Failed(errmsg), None), - crate::ws_messages::UpdateStatus::OutOfEnergy => (Self::OutOfEnergy, None), + ws::UpdateStatus::Committed(update) => (Self::Committed, Some(M::DbUpdate::parse_update(update)?)), + ws::UpdateStatus::Failed(errmsg) => (Self::Failed(errmsg), None), + ws::UpdateStatus::OutOfEnergy => (Self::OutOfEnergy, None), }) } } diff --git a/crates/sdk/src/lib.rs b/crates/sdk/src/lib.rs index 000ac419f52..c531aa26473 100644 --- a/crates/sdk/src/lib.rs +++ b/crates/sdk/src/lib.rs @@ -10,31 +10,12 @@ // code generated by the CLI's codegen references them, // but users should not. -#[doc(hidden)] -pub mod callbacks; -#[doc(hidden)] -pub mod client_cache; -#[doc(hidden)] -pub mod db_connection; -#[doc(hidden)] -pub mod spacetime_module; -#[doc(hidden)] -pub mod subscription; -#[doc(hidden)] -pub mod websocket; - -#[doc(hidden)] -pub use anyhow; -#[doc(hidden)] -pub use http; -#[doc(hidden)] -pub use log; -#[doc(hidden)] -pub use spacetimedb_client_api_messages::websocket as ws_messages; -#[doc(hidden)] -pub use spacetimedb_lib as lib; -#[doc(hidden)] -pub use spacetimedb_sats as sats; +mod callbacks; +mod client_cache; +mod db_connection; +mod spacetime_module; +mod subscription; +mod websocket; pub mod credentials; pub mod db_context; @@ -47,3 +28,40 @@ pub use event::{Event, ReducerEvent, Status}; pub use table::{Table, TableWithPrimaryKey}; pub use spacetimedb_lib::{Address, Identity, ScheduleAt}; +pub use spacetimedb_sats::{i256, u256}; + +#[doc(hidden)] +pub mod __codegen { + //! Names and definitions referenced by the CLI's codegen. + //! + //! Necessarily public, but should not be considered part of this library's public interface. + //! These may change incompatibly without a major version bump. + pub use anyhow; + pub use http; + pub use log; + pub use spacetimedb_client_api_messages::websocket as __ws; + pub use spacetimedb_lib as __lib; + pub use spacetimedb_sats as __sats; + + pub use crate::callbacks::{CallbackId, DbCallbacks}; + pub use crate::client_cache::{ClientCache, TableHandle, UniqueConstraintHandle}; + pub use crate::db_connection::DbContextImpl; + pub use crate::spacetime_module::{ + parse_reducer_args, DbConnection, DbUpdate, EventContext, InModule, Reducer, SpacetimeModule, + SubscriptionHandle, TableUpdate, + }; + pub use crate::subscription::{SubscriptionBuilder, SubscriptionHandleImpl}; + pub use crate::{ + Address, DbConnectionBuilder, DbContext, DisconnectedError, Event, Identity, ReducerEvent, ScheduleAt, Table, + TableWithPrimaryKey, + }; +} + +#[doc(hidden)] +pub mod unstable { + //! Unstable interfaces not ready for the prime time. + //! + //! These may change incompatibly without a major version bump. + pub use crate::db_connection::set_client_address; + pub use spacetimedb_client_api_messages::websocket::CallReducerFlags; +} diff --git a/crates/sdk/src/spacetime_module.rs b/crates/sdk/src/spacetime_module.rs index 159cac8bdff..1f7a1c69446 100644 --- a/crates/sdk/src/spacetime_module.rs +++ b/crates/sdk/src/spacetime_module.rs @@ -2,17 +2,16 @@ //! //! This module is internal, and may incompatibly change without warning. -use spacetimedb_client_api_messages::websocket::{BsatnFormat, RowListLen}; - use crate::{ callbacks::DbCallbacks, client_cache::ClientCache, db_connection::DbContextImpl, - subscription::SubscriptionHandleImpl, ws_messages as ws, Event, + subscription::SubscriptionHandleImpl, Event, }; use anyhow::Context; use bytes::Bytes; +use spacetimedb_client_api_messages::websocket::{self as ws, RowListLen as _}; use spacetimedb_data_structures::map::{DefaultHashBuilder, HashCollectionExt, HashMap}; use spacetimedb_lib::{bsatn, de::DeserializeOwned}; -use std::{any::Any, fmt::Debug, hash::Hash}; +use std::{fmt::Debug, hash::Hash}; /// Marker trait for any item defined in a module, /// to conveniently get the types of various per-module things. @@ -47,12 +46,16 @@ pub trait SpacetimeModule: Send + Sync + 'static { /// Module-specific `SubscriptionHandle` type, representing an ongoing incremental subscription to a query. type SubscriptionHandle: SubscriptionHandle; + + /// Called when constructing a [`Self::DbConnection`] on the new connection's [`ClientCache`] + /// to pre-register tables defined by the module, including their indices. + fn register_tables(client_cache: &mut ClientCache); } /// Implemented by the autogenerated `DbUpdate` type, /// which is a parsed and typed analogue of [`crate::ws::DatabaseUpdate`]. pub trait DbUpdate: - TryFrom, Error = anyhow::Error> + InModule + Send + 'static + TryFrom, Error = anyhow::Error> + InModule + Send + 'static where Self::Module: SpacetimeModule, { @@ -63,7 +66,7 @@ where callbacks: &mut DbCallbacks, ); - fn parse_update(update: ws::DatabaseUpdate) -> anyhow::Result { + fn parse_update(update: ws::DatabaseUpdate) -> anyhow::Result { Self::try_from(update).context("Failed to parse DatabaseUpdate from UpdateStatus") } } @@ -96,7 +99,7 @@ where /// which has a variant for each reducer defined by the module. /// This will be the type parameter to [`Event`] and [`crate::ReducerEvent`]. pub trait Reducer: - InModule + TryFrom, Error = anyhow::Error> + std::fmt::Debug + Send + 'static + InModule + TryFrom, Error = anyhow::Error> + std::fmt::Debug + Send + 'static where Self::Module: SpacetimeModule, { @@ -104,11 +107,6 @@ where /// /// Used by [`crate::callbacks::ReducerCallbacks::invoke_on_reducer`] to determine which callback to run. fn reducer_name(&self) -> &'static str; - /// Get a reference to the reducer argument struct for the variant stored in this instance. - /// - /// Used by [`crate::callbacks::ReducerCallbacks::invoke_on_reducer`] - /// to pass the reducer arguments to the callback. - fn reducer_args(&self) -> &dyn Any; } pub trait SubscriptionHandle: InModule + Send + 'static @@ -155,7 +153,7 @@ impl TableUpdate { /// merging pairs delete and insert pairs with matching values returned by `get_pk` into updates. // TODO: Weaker bound on `Pk`: must admit all SATS types. pub fn parse_table_update_with_primary_key( - raw_updates: ws::TableUpdate, + raw_updates: ws::TableUpdate, get_pk: fn(&Row) -> &Pk, ) -> anyhow::Result> { enum DiffEntry { @@ -253,7 +251,7 @@ impl TableUpdate { /// Parse `raw_updates` into a [`TableUpdate`] whose `updates` will always be empty. pub fn parse_table_update_no_primary_key( - raw_updates: ws::TableUpdate, + raw_updates: ws::TableUpdate, ) -> anyhow::Result> { let mut inserts = Vec::new(); let mut deletes = Vec::new(); diff --git a/crates/sdk/src/websocket.rs b/crates/sdk/src/websocket.rs index b2ccfd15742..23f3647ca17 100644 --- a/crates/sdk/src/websocket.rs +++ b/crates/sdk/src/websocket.rs @@ -2,7 +2,6 @@ //! //! This module is internal, and may incompatibly change without warning. -use crate::ws_messages::{ClientMessage, ServerMessage}; use anyhow::{anyhow, bail, Context, Result}; use bytes::Bytes; use futures::{SinkExt, StreamExt as _, TryStreamExt}; @@ -12,6 +11,7 @@ use spacetimedb_client_api_messages::websocket::{ brotli_decompress, gzip_decompress, BsatnFormat, Compression, SERVER_MSG_COMPRESSION_TAG_BROTLI, SERVER_MSG_COMPRESSION_TAG_GZIP, SERVER_MSG_COMPRESSION_TAG_NONE, }; +use spacetimedb_client_api_messages::websocket::{ClientMessage, ServerMessage}; use spacetimedb_lib::{bsatn, Address, Identity}; use tokio::task::JoinHandle; use tokio::{net::TcpStream, runtime}; diff --git a/crates/sdk/tests/connect_disconnect_client/src/module_bindings/connected_table.rs b/crates/sdk/tests/connect_disconnect_client/src/module_bindings/connected_table.rs index 5099d2f598a..8e2f91b12f4 100644 --- a/crates/sdk/tests/connect_disconnect_client/src/module_bindings/connected_table.rs +++ b/crates/sdk/tests/connect_disconnect_client/src/module_bindings/connected_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::connected_type::Connected; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `connected`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.connected().on_insert(...)`. pub struct ConnectedTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl ConnectedTableAccess for super::RemoteTables { } } -pub struct ConnectedInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct ConnectedDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct ConnectedInsertCallbackId(__sdk::CallbackId); +pub struct ConnectedDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for ConnectedTableHandle<'ctx> { +impl<'ctx> __sdk::Table for ConnectedTableHandle<'ctx> { type Row = Connected; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for ConnectedTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("connected"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"connected\"") } diff --git a/crates/sdk/tests/connect_disconnect_client/src/module_bindings/connected_type.rs b/crates/sdk/tests/connect_disconnect_client/src/module_bindings/connected_type.rs index 6413f7cf3a4..1cc8e9d80c5 100644 --- a/crates/sdk/tests/connect_disconnect_client/src/module_bindings/connected_type.rs +++ b/crates/sdk/tests/connect_disconnect_client/src/module_bindings/connected_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct Connected { pub identity: __sdk::Identity, } -impl __sdk::spacetime_module::InModule for Connected { +impl __sdk::InModule for Connected { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/connect_disconnect_client/src/module_bindings/disconnected_table.rs b/crates/sdk/tests/connect_disconnect_client/src/module_bindings/disconnected_table.rs index 8905a117917..5d056692435 100644 --- a/crates/sdk/tests/connect_disconnect_client/src/module_bindings/disconnected_table.rs +++ b/crates/sdk/tests/connect_disconnect_client/src/module_bindings/disconnected_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::disconnected_type::Disconnected; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `disconnected`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.disconnected().on_insert(...)`. pub struct DisconnectedTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl DisconnectedTableAccess for super::RemoteTables { } } -pub struct DisconnectedInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct DisconnectedDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct DisconnectedInsertCallbackId(__sdk::CallbackId); +pub struct DisconnectedDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for DisconnectedTableHandle<'ctx> { +impl<'ctx> __sdk::Table for DisconnectedTableHandle<'ctx> { type Row = Disconnected; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for DisconnectedTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("disconnected"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"disconnected\"") } diff --git a/crates/sdk/tests/connect_disconnect_client/src/module_bindings/disconnected_type.rs b/crates/sdk/tests/connect_disconnect_client/src/module_bindings/disconnected_type.rs index 5df0f7343e4..9a466a0151d 100644 --- a/crates/sdk/tests/connect_disconnect_client/src/module_bindings/disconnected_type.rs +++ b/crates/sdk/tests/connect_disconnect_client/src/module_bindings/disconnected_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct Disconnected { pub identity: __sdk::Identity, } -impl __sdk::spacetime_module::InModule for Disconnected { +impl __sdk::InModule for Disconnected { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/connect_disconnect_client/src/module_bindings/identity_connected_reducer.rs b/crates/sdk/tests/connect_disconnect_client/src/module_bindings/identity_connected_reducer.rs index f15e0b3f320..fafba96a97b 100644 --- a/crates/sdk/tests/connect_disconnect_client/src/module_bindings/identity_connected_reducer.rs +++ b/crates/sdk/tests/connect_disconnect_client/src/module_bindings/identity_connected_reducer.rs @@ -2,21 +2,26 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct IdentityConnected {} +pub(super) struct IdentityConnectedArgs {} -impl __sdk::spacetime_module::InModule for IdentityConnected { +impl From for super::Reducer { + fn from(args: IdentityConnectedArgs) -> Self { + Self::IdentityConnected + } +} + +impl __sdk::InModule for IdentityConnectedArgs { type Module = super::RemoteModule; } -pub struct IdentityConnectedCallbackId(__sdk::callbacks::CallbackId); +pub struct IdentityConnectedCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `__identity_connected__`. @@ -50,20 +55,33 @@ pub trait identity_connected { impl identity_connected for super::RemoteReducers { fn identity_connected(&self) -> __anyhow::Result<()> { - self.imp.call_reducer("__identity_connected__", IdentityConnected {}) + self.imp + .call_reducer("__identity_connected__", IdentityConnectedArgs {}) } fn on_identity_connected( &self, mut callback: impl FnMut(&super::EventContext) + Send + 'static, ) -> IdentityConnectedCallbackId { - IdentityConnectedCallbackId(self.imp.on_reducer::( + IdentityConnectedCallbackId(self.imp.on_reducer( "__identity_connected__", - Box::new(move |ctx: &super::EventContext, args: &IdentityConnected| callback(ctx)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::IdentityConnected {}, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx) + }), )) } fn remove_on_identity_connected(&self, callback: IdentityConnectedCallbackId) { - self.imp - .remove_on_reducer::("__identity_connected__", callback.0) + self.imp.remove_on_reducer("__identity_connected__", callback.0) } } diff --git a/crates/sdk/tests/connect_disconnect_client/src/module_bindings/identity_disconnected_reducer.rs b/crates/sdk/tests/connect_disconnect_client/src/module_bindings/identity_disconnected_reducer.rs index 539ad0ecd03..0f48475e772 100644 --- a/crates/sdk/tests/connect_disconnect_client/src/module_bindings/identity_disconnected_reducer.rs +++ b/crates/sdk/tests/connect_disconnect_client/src/module_bindings/identity_disconnected_reducer.rs @@ -2,21 +2,26 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct IdentityDisconnected {} +pub(super) struct IdentityDisconnectedArgs {} -impl __sdk::spacetime_module::InModule for IdentityDisconnected { +impl From for super::Reducer { + fn from(args: IdentityDisconnectedArgs) -> Self { + Self::IdentityDisconnected + } +} + +impl __sdk::InModule for IdentityDisconnectedArgs { type Module = super::RemoteModule; } -pub struct IdentityDisconnectedCallbackId(__sdk::callbacks::CallbackId); +pub struct IdentityDisconnectedCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `__identity_disconnected__`. @@ -51,20 +56,32 @@ pub trait identity_disconnected { impl identity_disconnected for super::RemoteReducers { fn identity_disconnected(&self) -> __anyhow::Result<()> { self.imp - .call_reducer("__identity_disconnected__", IdentityDisconnected {}) + .call_reducer("__identity_disconnected__", IdentityDisconnectedArgs {}) } fn on_identity_disconnected( &self, mut callback: impl FnMut(&super::EventContext) + Send + 'static, ) -> IdentityDisconnectedCallbackId { - IdentityDisconnectedCallbackId(self.imp.on_reducer::( + IdentityDisconnectedCallbackId(self.imp.on_reducer( "__identity_disconnected__", - Box::new(move |ctx: &super::EventContext, args: &IdentityDisconnected| callback(ctx)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::IdentityDisconnected {}, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx) + }), )) } fn remove_on_identity_disconnected(&self, callback: IdentityDisconnectedCallbackId) { - self.imp - .remove_on_reducer::("__identity_disconnected__", callback.0) + self.imp.remove_on_reducer("__identity_disconnected__", callback.0) } } diff --git a/crates/sdk/tests/connect_disconnect_client/src/module_bindings/mod.rs b/crates/sdk/tests/connect_disconnect_client/src/module_bindings/mod.rs index f73114a1878..4e8fc490e37 100644 --- a/crates/sdk/tests/connect_disconnect_client/src/module_bindings/mod.rs +++ b/crates/sdk/tests/connect_disconnect_client/src/module_bindings/mod.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; pub mod connected_table; @@ -16,14 +15,17 @@ pub mod identity_connected_reducer; pub mod identity_disconnected_reducer; pub use connected_table::*; -pub use connected_type::*; +pub use connected_type::Connected; pub use disconnected_table::*; -pub use disconnected_type::*; -pub use identity_connected_reducer::*; -pub use identity_disconnected_reducer::*; +pub use disconnected_type::Disconnected; +pub use identity_connected_reducer::{ + identity_connected, set_flags_for_identity_connected, IdentityConnectedCallbackId, +}; +pub use identity_disconnected_reducer::{ + identity_disconnected, set_flags_for_identity_disconnected, IdentityDisconnectedCallbackId, +}; -#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] -#[sats(crate = __lib)] +#[derive(Clone, PartialEq, Debug)] /// One of the reducers defined by this module. /// @@ -31,25 +33,19 @@ pub use identity_disconnected_reducer::*; /// to indicate which reducer caused the event. pub enum Reducer { - IdentityConnected(identity_connected_reducer::IdentityConnected), - IdentityDisconnected(identity_disconnected_reducer::IdentityDisconnected), + IdentityConnected, + IdentityDisconnected, } -impl __sdk::spacetime_module::InModule for Reducer { +impl __sdk::InModule for Reducer { type Module = RemoteModule; } -impl __sdk::spacetime_module::Reducer for Reducer { +impl __sdk::Reducer for Reducer { fn reducer_name(&self) -> &'static str { match self { - Reducer::IdentityConnected(_) => "__identity_connected__", - Reducer::IdentityDisconnected(_) => "__identity_disconnected__", - } - } - fn reducer_args(&self) -> &dyn std::any::Any { - match self { - Reducer::IdentityConnected(args) => args, - Reducer::IdentityDisconnected(args) => args, + Reducer::IdentityConnected => "__identity_connected__", + Reducer::IdentityDisconnected => "__identity_disconnected__", } } } @@ -57,13 +53,14 @@ impl TryFrom<__ws::ReducerCallInfo<__ws::BsatnFormat>> for Reducer { type Error = __anyhow::Error; fn try_from(value: __ws::ReducerCallInfo<__ws::BsatnFormat>) -> __anyhow::Result { match &value.reducer_name[..] { - "__identity_connected__" => Ok(Reducer::IdentityConnected(__sdk::spacetime_module::parse_reducer_args( - "__identity_connected__", - &value.args, - )?)), - "__identity_disconnected__" => Ok(Reducer::IdentityDisconnected( - __sdk::spacetime_module::parse_reducer_args("__identity_disconnected__", &value.args)?, - )), + "__identity_connected__" => Ok(__sdk::parse_reducer_args::< + identity_connected_reducer::IdentityConnectedArgs, + >("__identity_connected__", &value.args)? + .into()), + "__identity_disconnected__" => Ok(__sdk::parse_reducer_args::< + identity_disconnected_reducer::IdentityDisconnectedArgs, + >("__identity_disconnected__", &value.args)? + .into()), _ => Err(__anyhow::anyhow!("Unknown reducer {:?}", value.reducer_name)), } } @@ -73,8 +70,8 @@ impl TryFrom<__ws::ReducerCallInfo<__ws::BsatnFormat>> for Reducer { #[allow(non_snake_case)] #[doc(hidden)] pub struct DbUpdate { - connected: __sdk::spacetime_module::TableUpdate, - disconnected: __sdk::spacetime_module::TableUpdate, + connected: __sdk::TableUpdate, + disconnected: __sdk::TableUpdate, } impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate { @@ -93,16 +90,16 @@ impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate { } } -impl __sdk::spacetime_module::InModule for DbUpdate { +impl __sdk::InModule for DbUpdate { type Module = RemoteModule; } -impl __sdk::spacetime_module::DbUpdate for DbUpdate { - fn apply_to_client_cache(&self, cache: &mut __sdk::client_cache::ClientCache) { +impl __sdk::DbUpdate for DbUpdate { + fn apply_to_client_cache(&self, cache: &mut __sdk::ClientCache) { cache.apply_diff_to_table::("connected", &self.connected); cache.apply_diff_to_table::("disconnected", &self.disconnected); } - fn invoke_row_callbacks(&self, event: &EventContext, callbacks: &mut __sdk::callbacks::DbCallbacks) { + fn invoke_row_callbacks(&self, event: &EventContext, callbacks: &mut __sdk::DbCallbacks) { callbacks.invoke_table_row_callbacks::("connected", &self.connected, event); callbacks.invoke_table_row_callbacks::("disconnected", &self.disconnected, event); } @@ -111,28 +108,17 @@ impl __sdk::spacetime_module::DbUpdate for DbUpdate { #[doc(hidden)] pub struct RemoteModule; -impl __sdk::spacetime_module::InModule for RemoteModule { +impl __sdk::InModule for RemoteModule { type Module = Self; } -impl __sdk::spacetime_module::SpacetimeModule for RemoteModule { - type DbConnection = DbConnection; - type EventContext = EventContext; - type Reducer = Reducer; - type DbView = RemoteTables; - type Reducers = RemoteReducers; - type SetReducerFlags = SetReducerFlags; - type DbUpdate = DbUpdate; - type SubscriptionHandle = SubscriptionHandle; -} - /// The `reducers` field of [`EventContext`] and [`DbConnection`], /// with methods provided by extension traits for each reducer defined by the module. pub struct RemoteReducers { - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for RemoteReducers { +impl __sdk::InModule for RemoteReducers { type Module = RemoteModule; } @@ -143,20 +129,20 @@ impl __sdk::spacetime_module::InModule for RemoteReducers { /// /// This type is currently unstable and may be removed without a major version bump. pub struct SetReducerFlags { - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for SetReducerFlags { +impl __sdk::InModule for SetReducerFlags { type Module = RemoteModule; } /// The `db` field of [`EventContext`] and [`DbConnection`], /// with methods provided by extension traits for each table defined by the module. pub struct RemoteTables { - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for RemoteTables { +impl __sdk::InModule for RemoteTables { type Module = RemoteModule; } @@ -188,14 +174,14 @@ pub struct DbConnection { /// This type is currently unstable and may be removed without a major version bump. pub set_reducer_flags: SetReducerFlags, - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for DbConnection { +impl __sdk::InModule for DbConnection { type Module = RemoteModule; } -impl __sdk::db_context::DbContext for DbConnection { +impl __sdk::DbContext for DbConnection { type DbView = RemoteTables; type Reducers = RemoteReducers; type SetReducerFlags = SetReducerFlags; @@ -218,10 +204,10 @@ impl __sdk::db_context::DbContext for DbConnection { self.imp.disconnect() } - type SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder; + type SubscriptionBuilder = __sdk::SubscriptionBuilder; fn subscription_builder(&self) -> Self::SubscriptionBuilder { - __sdk::subscription::SubscriptionBuilder::new(&self.imp) + __sdk::SubscriptionBuilder::new(&self.imp) } fn try_identity(&self) -> Option<__sdk::Identity> { @@ -237,7 +223,7 @@ impl DbConnection { /// /// See [`__sdk::DbConnectionBuilder`] for required and optional configuration for the new connection. pub fn builder() -> __sdk::DbConnectionBuilder { - __sdk::db_connection::DbConnectionBuilder::new() + __sdk::DbConnectionBuilder::new() } /// If any WebSocket messages are waiting, process one of them. @@ -303,8 +289,8 @@ impl DbConnection { } } -impl __sdk::spacetime_module::DbConnection for DbConnection { - fn new(imp: __sdk::db_connection::DbContextImpl) -> Self { +impl __sdk::DbConnection for DbConnection { + fn new(imp: __sdk::DbContextImpl) -> Self { Self { db: RemoteTables { imp: imp.clone() }, reducers: RemoteReducers { imp: imp.clone() }, @@ -327,15 +313,15 @@ pub struct EventContext { /// This type is currently unstable and may be removed without a major version bump. pub set_reducer_flags: SetReducerFlags, /// The event which caused these callbacks to run. - pub event: __sdk::event::Event, - imp: __sdk::db_connection::DbContextImpl, + pub event: __sdk::Event, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for EventContext { +impl __sdk::InModule for EventContext { type Module = RemoteModule; } -impl __sdk::db_context::DbContext for EventContext { +impl __sdk::DbContext for EventContext { type DbView = RemoteTables; type Reducers = RemoteReducers; type SetReducerFlags = SetReducerFlags; @@ -354,14 +340,14 @@ impl __sdk::db_context::DbContext for EventContext { self.imp.is_active() } - fn disconnect(&self) -> spacetimedb_sdk::anyhow::Result<()> { + fn disconnect(&self) -> __anyhow::Result<()> { self.imp.disconnect() } - type SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder; + type SubscriptionBuilder = __sdk::SubscriptionBuilder; fn subscription_builder(&self) -> Self::SubscriptionBuilder { - __sdk::subscription::SubscriptionBuilder::new(&self.imp) + __sdk::SubscriptionBuilder::new(&self.imp) } fn try_identity(&self) -> Option<__sdk::Identity> { @@ -372,11 +358,11 @@ impl __sdk::db_context::DbContext for EventContext { } } -impl __sdk::spacetime_module::EventContext for EventContext { - fn event(&self) -> &__sdk::event::Event { +impl __sdk::EventContext for EventContext { + fn event(&self) -> &__sdk::Event { &self.event } - fn new(imp: __sdk::db_connection::DbContextImpl, event: __sdk::event::Event) -> Self { + fn new(imp: __sdk::DbContextImpl, event: __sdk::Event) -> Self { Self { db: RemoteTables { imp: imp.clone() }, reducers: RemoteReducers { imp: imp.clone() }, @@ -390,15 +376,15 @@ impl __sdk::spacetime_module::EventContext for EventContext { /// A handle on a subscribed query. // TODO: Document this better after implementing the new subscription API. pub struct SubscriptionHandle { - imp: __sdk::subscription::SubscriptionHandleImpl, + imp: __sdk::SubscriptionHandleImpl, } -impl __sdk::spacetime_module::InModule for SubscriptionHandle { +impl __sdk::InModule for SubscriptionHandle { type Module = RemoteModule; } -impl __sdk::spacetime_module::SubscriptionHandle for SubscriptionHandle { - fn new(imp: __sdk::subscription::SubscriptionHandleImpl) -> Self { +impl __sdk::SubscriptionHandle for SubscriptionHandle { + fn new(imp: __sdk::SubscriptionHandleImpl) -> Self { Self { imp } } } @@ -413,7 +399,7 @@ pub trait RemoteDbContext: DbView = RemoteTables, Reducers = RemoteReducers, SetReducerFlags = SetReducerFlags, - SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder, + SubscriptionBuilder = __sdk::SubscriptionBuilder, > { } @@ -422,8 +408,24 @@ impl< DbView = RemoteTables, Reducers = RemoteReducers, SetReducerFlags = SetReducerFlags, - SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder, + SubscriptionBuilder = __sdk::SubscriptionBuilder, >, > RemoteDbContext for Ctx { } + +impl __sdk::SpacetimeModule for RemoteModule { + type DbConnection = DbConnection; + type EventContext = EventContext; + type Reducer = Reducer; + type DbView = RemoteTables; + type Reducers = RemoteReducers; + type SetReducerFlags = SetReducerFlags; + type DbUpdate = DbUpdate; + type SubscriptionHandle = SubscriptionHandle; + + fn register_tables(client_cache: &mut __sdk::ClientCache) { + connected_table::register_table(client_cache); + disconnected_table::register_table(client_cache); + } +} diff --git a/crates/sdk/tests/test-client/src/main.rs b/crates/sdk/tests/test-client/src/main.rs index 09f5ef218e9..d9a9ec8835a 100644 --- a/crates/sdk/tests/test-client/src/main.rs +++ b/crates/sdk/tests/test-client/src/main.rs @@ -5,9 +5,8 @@ mod module_bindings; use module_bindings::*; use spacetimedb_sdk::{ - credentials, - sats::{i256, u256}, - Address, DbContext, Event, Identity, ReducerEvent, Status, Table, + credentials, i256, u256, Address, DbContext, Event, Identity, + ReducerEvent, Status, Table, }; use test_counter::TestCounter; @@ -498,7 +497,7 @@ fn exec_insert_caller_identity() { move |ctx| { subscribe_all_then(ctx, move |ctx| { on_insert_one::(ctx, &test_counter, ctx.identity(), |event| { - matches!(event, Reducer::InsertCallerOneIdentity(_)) + matches!(event, Reducer::InsertCallerOneIdentity) }); ctx.reducers.insert_caller_one_identity().unwrap(); @@ -583,7 +582,7 @@ fn exec_insert_caller_address() { move |ctx| { subscribe_all_then(ctx, move |ctx| { on_insert_one::(ctx, &test_counter, ctx.address(), |event| { - matches!(event, Reducer::InsertCallerOneAddress(_)) + matches!(event, Reducer::InsertCallerOneAddress) }); ctx.reducers.insert_caller_one_address().unwrap(); sub_applied_nothing_result(assert_all_tables_empty(ctx)); @@ -683,7 +682,7 @@ fn exec_on_reducer() { reducer_event.status ); } - let expected_reducer = Reducer::InsertOneU8(InsertOneU8 { n: value }); + let expected_reducer = Reducer::InsertOneU8 { n: value }; if reducer_event.reducer != expected_reducer { anyhow::bail!( "Unexpected Reducer in ReducerEvent: expected {expected_reducer:?} but found {:?}", @@ -766,10 +765,10 @@ fn exec_fail_reducer() { reducer_event.status ); } - let expected_reducer = Reducer::InsertPkU8(InsertPkU8 { + let expected_reducer = Reducer::InsertPkU8 { n: key, data: initial_data, - }); + }; if reducer_event.reducer != expected_reducer { anyhow::bail!( "Unexpected Reducer in ReducerEvent: expected {expected_reducer:?} but found {:?}", @@ -832,10 +831,10 @@ fn exec_fail_reducer() { reducer_event.status ); } - let expected_reducer = Reducer::InsertPkU8(InsertPkU8 { + let expected_reducer = Reducer::InsertPkU8 { n: key, data: fail_data, - }); + }; if reducer_event.reducer != expected_reducer { anyhow::bail!( "Unexpected Reducer in ReducerEvent: expected {expected_reducer:?} but found {:?}", @@ -1192,7 +1191,7 @@ fn exec_insert_long_table() { if !matches!( ctx.event, Event::Reducer(ReducerEvent { - reducer: Reducer::InsertLargeTable(_), + reducer: Reducer::InsertLargeTable { .. }, .. }) ) { @@ -1279,7 +1278,7 @@ fn exec_insert_primitives_as_strings() { ctx.event, Event::Reducer(ReducerEvent { status: Status::Committed, - reducer: Reducer::InsertPrimitivesAsStrings(_), + reducer: Reducer::InsertPrimitivesAsStrings { .. }, .. }) ) { @@ -1536,7 +1535,7 @@ fn exec_caller_always_notified() { (no_op_result.take().unwrap())(match ctx.event { Event::Reducer(ReducerEvent { status: Status::Committed, - reducer: Reducer::NoOpSucceeds(_), + reducer: Reducer::NoOpSucceeds, .. }) => Ok(()), _ => Err(anyhow::anyhow!( diff --git a/crates/sdk/tests/test-client/src/module_bindings/byte_struct_type.rs b/crates/sdk/tests/test-client/src/module_bindings/byte_struct_type.rs index 14dce71e242..6554ff02e29 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/byte_struct_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/byte_struct_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct ByteStruct { pub b: u8, } -impl __sdk::spacetime_module::InModule for ByteStruct { +impl __sdk::InModule for ByteStruct { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_address_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_address_reducer.rs index ef302a66de4..1bc3d87da50 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_address_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_address_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePkAddress { +pub(super) struct DeletePkAddressArgs { pub a: __sdk::Address, } -impl __sdk::spacetime_module::InModule for DeletePkAddress { +impl From for super::Reducer { + fn from(args: DeletePkAddressArgs) -> Self { + Self::DeletePkAddress { a: args.a } + } +} + +impl __sdk::InModule for DeletePkAddressArgs { type Module = super::RemoteModule; } -pub struct DeletePkAddressCallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePkAddressCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_pk_address`. @@ -52,20 +57,32 @@ pub trait delete_pk_address { impl delete_pk_address for super::RemoteReducers { fn delete_pk_address(&self, a: __sdk::Address) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_pk_address", DeletePkAddress { a }) + self.imp.call_reducer("delete_pk_address", DeletePkAddressArgs { a }) } fn on_delete_pk_address( &self, mut callback: impl FnMut(&super::EventContext, &__sdk::Address) + Send + 'static, ) -> DeletePkAddressCallbackId { - DeletePkAddressCallbackId(self.imp.on_reducer::( + DeletePkAddressCallbackId(self.imp.on_reducer( "delete_pk_address", - Box::new(move |ctx: &super::EventContext, args: &DeletePkAddress| callback(ctx, &args.a)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePkAddress { a }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, a) + }), )) } fn remove_on_delete_pk_address(&self, callback: DeletePkAddressCallbackId) { - self.imp - .remove_on_reducer::("delete_pk_address", callback.0) + self.imp.remove_on_reducer("delete_pk_address", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_bool_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_bool_reducer.rs index bad581aa9cb..7d863f3f897 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_bool_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_bool_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePkBool { +pub(super) struct DeletePkBoolArgs { pub b: bool, } -impl __sdk::spacetime_module::InModule for DeletePkBool { +impl From for super::Reducer { + fn from(args: DeletePkBoolArgs) -> Self { + Self::DeletePkBool { b: args.b } + } +} + +impl __sdk::InModule for DeletePkBoolArgs { type Module = super::RemoteModule; } -pub struct DeletePkBoolCallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePkBoolCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_pk_bool`. @@ -52,19 +57,32 @@ pub trait delete_pk_bool { impl delete_pk_bool for super::RemoteReducers { fn delete_pk_bool(&self, b: bool) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_pk_bool", DeletePkBool { b }) + self.imp.call_reducer("delete_pk_bool", DeletePkBoolArgs { b }) } fn on_delete_pk_bool( &self, mut callback: impl FnMut(&super::EventContext, &bool) + Send + 'static, ) -> DeletePkBoolCallbackId { - DeletePkBoolCallbackId(self.imp.on_reducer::( + DeletePkBoolCallbackId(self.imp.on_reducer( "delete_pk_bool", - Box::new(move |ctx: &super::EventContext, args: &DeletePkBool| callback(ctx, &args.b)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePkBool { b }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, b) + }), )) } fn remove_on_delete_pk_bool(&self, callback: DeletePkBoolCallbackId) { - self.imp.remove_on_reducer::("delete_pk_bool", callback.0) + self.imp.remove_on_reducer("delete_pk_bool", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_128_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_128_reducer.rs index 37d809e71b8..68d01c64ba4 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_128_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_128_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePkI128 { +pub(super) struct DeletePkI128Args { pub n: i128, } -impl __sdk::spacetime_module::InModule for DeletePkI128 { +impl From for super::Reducer { + fn from(args: DeletePkI128Args) -> Self { + Self::DeletePkI128 { n: args.n } + } +} + +impl __sdk::InModule for DeletePkI128Args { type Module = super::RemoteModule; } -pub struct DeletePkI128CallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePkI128CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_pk_i128`. @@ -52,19 +57,32 @@ pub trait delete_pk_i_128 { impl delete_pk_i_128 for super::RemoteReducers { fn delete_pk_i_128(&self, n: i128) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_pk_i128", DeletePkI128 { n }) + self.imp.call_reducer("delete_pk_i128", DeletePkI128Args { n }) } fn on_delete_pk_i_128( &self, mut callback: impl FnMut(&super::EventContext, &i128) + Send + 'static, ) -> DeletePkI128CallbackId { - DeletePkI128CallbackId(self.imp.on_reducer::( + DeletePkI128CallbackId(self.imp.on_reducer( "delete_pk_i128", - Box::new(move |ctx: &super::EventContext, args: &DeletePkI128| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePkI128 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_pk_i_128(&self, callback: DeletePkI128CallbackId) { - self.imp.remove_on_reducer::("delete_pk_i128", callback.0) + self.imp.remove_on_reducer("delete_pk_i128", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_16_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_16_reducer.rs index fc5b3576d2f..1dc0b9eaf51 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_16_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_16_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePkI16 { +pub(super) struct DeletePkI16Args { pub n: i16, } -impl __sdk::spacetime_module::InModule for DeletePkI16 { +impl From for super::Reducer { + fn from(args: DeletePkI16Args) -> Self { + Self::DeletePkI16 { n: args.n } + } +} + +impl __sdk::InModule for DeletePkI16Args { type Module = super::RemoteModule; } -pub struct DeletePkI16CallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePkI16CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_pk_i16`. @@ -52,19 +57,32 @@ pub trait delete_pk_i_16 { impl delete_pk_i_16 for super::RemoteReducers { fn delete_pk_i_16(&self, n: i16) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_pk_i16", DeletePkI16 { n }) + self.imp.call_reducer("delete_pk_i16", DeletePkI16Args { n }) } fn on_delete_pk_i_16( &self, mut callback: impl FnMut(&super::EventContext, &i16) + Send + 'static, ) -> DeletePkI16CallbackId { - DeletePkI16CallbackId(self.imp.on_reducer::( + DeletePkI16CallbackId(self.imp.on_reducer( "delete_pk_i16", - Box::new(move |ctx: &super::EventContext, args: &DeletePkI16| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePkI16 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_pk_i_16(&self, callback: DeletePkI16CallbackId) { - self.imp.remove_on_reducer::("delete_pk_i16", callback.0) + self.imp.remove_on_reducer("delete_pk_i16", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_256_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_256_reducer.rs index fa3e0f10647..71a78b041f4 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_256_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_256_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePkI256 { +pub(super) struct DeletePkI256Args { pub n: __sats::i256, } -impl __sdk::spacetime_module::InModule for DeletePkI256 { +impl From for super::Reducer { + fn from(args: DeletePkI256Args) -> Self { + Self::DeletePkI256 { n: args.n } + } +} + +impl __sdk::InModule for DeletePkI256Args { type Module = super::RemoteModule; } -pub struct DeletePkI256CallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePkI256CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_pk_i256`. @@ -52,19 +57,32 @@ pub trait delete_pk_i_256 { impl delete_pk_i_256 for super::RemoteReducers { fn delete_pk_i_256(&self, n: __sats::i256) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_pk_i256", DeletePkI256 { n }) + self.imp.call_reducer("delete_pk_i256", DeletePkI256Args { n }) } fn on_delete_pk_i_256( &self, mut callback: impl FnMut(&super::EventContext, &__sats::i256) + Send + 'static, ) -> DeletePkI256CallbackId { - DeletePkI256CallbackId(self.imp.on_reducer::( + DeletePkI256CallbackId(self.imp.on_reducer( "delete_pk_i256", - Box::new(move |ctx: &super::EventContext, args: &DeletePkI256| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePkI256 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_pk_i_256(&self, callback: DeletePkI256CallbackId) { - self.imp.remove_on_reducer::("delete_pk_i256", callback.0) + self.imp.remove_on_reducer("delete_pk_i256", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_32_reducer.rs index 2b958640d52..76acbb0754a 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_32_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePkI32 { +pub(super) struct DeletePkI32Args { pub n: i32, } -impl __sdk::spacetime_module::InModule for DeletePkI32 { +impl From for super::Reducer { + fn from(args: DeletePkI32Args) -> Self { + Self::DeletePkI32 { n: args.n } + } +} + +impl __sdk::InModule for DeletePkI32Args { type Module = super::RemoteModule; } -pub struct DeletePkI32CallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePkI32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_pk_i32`. @@ -52,19 +57,32 @@ pub trait delete_pk_i_32 { impl delete_pk_i_32 for super::RemoteReducers { fn delete_pk_i_32(&self, n: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_pk_i32", DeletePkI32 { n }) + self.imp.call_reducer("delete_pk_i32", DeletePkI32Args { n }) } fn on_delete_pk_i_32( &self, mut callback: impl FnMut(&super::EventContext, &i32) + Send + 'static, ) -> DeletePkI32CallbackId { - DeletePkI32CallbackId(self.imp.on_reducer::( + DeletePkI32CallbackId(self.imp.on_reducer( "delete_pk_i32", - Box::new(move |ctx: &super::EventContext, args: &DeletePkI32| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePkI32 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_pk_i_32(&self, callback: DeletePkI32CallbackId) { - self.imp.remove_on_reducer::("delete_pk_i32", callback.0) + self.imp.remove_on_reducer("delete_pk_i32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_64_reducer.rs index 34330ea4201..d95f7495d51 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_64_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePkI64 { +pub(super) struct DeletePkI64Args { pub n: i64, } -impl __sdk::spacetime_module::InModule for DeletePkI64 { +impl From for super::Reducer { + fn from(args: DeletePkI64Args) -> Self { + Self::DeletePkI64 { n: args.n } + } +} + +impl __sdk::InModule for DeletePkI64Args { type Module = super::RemoteModule; } -pub struct DeletePkI64CallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePkI64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_pk_i64`. @@ -52,19 +57,32 @@ pub trait delete_pk_i_64 { impl delete_pk_i_64 for super::RemoteReducers { fn delete_pk_i_64(&self, n: i64) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_pk_i64", DeletePkI64 { n }) + self.imp.call_reducer("delete_pk_i64", DeletePkI64Args { n }) } fn on_delete_pk_i_64( &self, mut callback: impl FnMut(&super::EventContext, &i64) + Send + 'static, ) -> DeletePkI64CallbackId { - DeletePkI64CallbackId(self.imp.on_reducer::( + DeletePkI64CallbackId(self.imp.on_reducer( "delete_pk_i64", - Box::new(move |ctx: &super::EventContext, args: &DeletePkI64| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePkI64 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_pk_i_64(&self, callback: DeletePkI64CallbackId) { - self.imp.remove_on_reducer::("delete_pk_i64", callback.0) + self.imp.remove_on_reducer("delete_pk_i64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_8_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_8_reducer.rs index 94e022f6ada..70be2f42e3e 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_8_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_i_8_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePkI8 { +pub(super) struct DeletePkI8Args { pub n: i8, } -impl __sdk::spacetime_module::InModule for DeletePkI8 { +impl From for super::Reducer { + fn from(args: DeletePkI8Args) -> Self { + Self::DeletePkI8 { n: args.n } + } +} + +impl __sdk::InModule for DeletePkI8Args { type Module = super::RemoteModule; } -pub struct DeletePkI8CallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePkI8CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_pk_i8`. @@ -52,19 +57,32 @@ pub trait delete_pk_i_8 { impl delete_pk_i_8 for super::RemoteReducers { fn delete_pk_i_8(&self, n: i8) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_pk_i8", DeletePkI8 { n }) + self.imp.call_reducer("delete_pk_i8", DeletePkI8Args { n }) } fn on_delete_pk_i_8( &self, mut callback: impl FnMut(&super::EventContext, &i8) + Send + 'static, ) -> DeletePkI8CallbackId { - DeletePkI8CallbackId(self.imp.on_reducer::( + DeletePkI8CallbackId(self.imp.on_reducer( "delete_pk_i8", - Box::new(move |ctx: &super::EventContext, args: &DeletePkI8| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePkI8 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_pk_i_8(&self, callback: DeletePkI8CallbackId) { - self.imp.remove_on_reducer::("delete_pk_i8", callback.0) + self.imp.remove_on_reducer("delete_pk_i8", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_identity_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_identity_reducer.rs index ee73a1d1a77..438c52fcc7f 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_identity_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_identity_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePkIdentity { +pub(super) struct DeletePkIdentityArgs { pub i: __sdk::Identity, } -impl __sdk::spacetime_module::InModule for DeletePkIdentity { +impl From for super::Reducer { + fn from(args: DeletePkIdentityArgs) -> Self { + Self::DeletePkIdentity { i: args.i } + } +} + +impl __sdk::InModule for DeletePkIdentityArgs { type Module = super::RemoteModule; } -pub struct DeletePkIdentityCallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePkIdentityCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_pk_identity`. @@ -52,20 +57,32 @@ pub trait delete_pk_identity { impl delete_pk_identity for super::RemoteReducers { fn delete_pk_identity(&self, i: __sdk::Identity) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_pk_identity", DeletePkIdentity { i }) + self.imp.call_reducer("delete_pk_identity", DeletePkIdentityArgs { i }) } fn on_delete_pk_identity( &self, mut callback: impl FnMut(&super::EventContext, &__sdk::Identity) + Send + 'static, ) -> DeletePkIdentityCallbackId { - DeletePkIdentityCallbackId(self.imp.on_reducer::( + DeletePkIdentityCallbackId(self.imp.on_reducer( "delete_pk_identity", - Box::new(move |ctx: &super::EventContext, args: &DeletePkIdentity| callback(ctx, &args.i)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePkIdentity { i }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, i) + }), )) } fn remove_on_delete_pk_identity(&self, callback: DeletePkIdentityCallbackId) { - self.imp - .remove_on_reducer::("delete_pk_identity", callback.0) + self.imp.remove_on_reducer("delete_pk_identity", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_string_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_string_reducer.rs index 5cdbb0814b9..cb91771edb4 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_string_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_string_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePkString { +pub(super) struct DeletePkStringArgs { pub s: String, } -impl __sdk::spacetime_module::InModule for DeletePkString { +impl From for super::Reducer { + fn from(args: DeletePkStringArgs) -> Self { + Self::DeletePkString { s: args.s } + } +} + +impl __sdk::InModule for DeletePkStringArgs { type Module = super::RemoteModule; } -pub struct DeletePkStringCallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePkStringCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_pk_string`. @@ -52,20 +57,32 @@ pub trait delete_pk_string { impl delete_pk_string for super::RemoteReducers { fn delete_pk_string(&self, s: String) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_pk_string", DeletePkString { s }) + self.imp.call_reducer("delete_pk_string", DeletePkStringArgs { s }) } fn on_delete_pk_string( &self, mut callback: impl FnMut(&super::EventContext, &String) + Send + 'static, ) -> DeletePkStringCallbackId { - DeletePkStringCallbackId(self.imp.on_reducer::( + DeletePkStringCallbackId(self.imp.on_reducer( "delete_pk_string", - Box::new(move |ctx: &super::EventContext, args: &DeletePkString| callback(ctx, &args.s)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePkString { s }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s) + }), )) } fn remove_on_delete_pk_string(&self, callback: DeletePkStringCallbackId) { - self.imp - .remove_on_reducer::("delete_pk_string", callback.0) + self.imp.remove_on_reducer("delete_pk_string", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_128_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_128_reducer.rs index da5b69c3952..e4a5d9e9ed8 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_128_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_128_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePkU128 { +pub(super) struct DeletePkU128Args { pub n: u128, } -impl __sdk::spacetime_module::InModule for DeletePkU128 { +impl From for super::Reducer { + fn from(args: DeletePkU128Args) -> Self { + Self::DeletePkU128 { n: args.n } + } +} + +impl __sdk::InModule for DeletePkU128Args { type Module = super::RemoteModule; } -pub struct DeletePkU128CallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePkU128CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_pk_u128`. @@ -52,19 +57,32 @@ pub trait delete_pk_u_128 { impl delete_pk_u_128 for super::RemoteReducers { fn delete_pk_u_128(&self, n: u128) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_pk_u128", DeletePkU128 { n }) + self.imp.call_reducer("delete_pk_u128", DeletePkU128Args { n }) } fn on_delete_pk_u_128( &self, mut callback: impl FnMut(&super::EventContext, &u128) + Send + 'static, ) -> DeletePkU128CallbackId { - DeletePkU128CallbackId(self.imp.on_reducer::( + DeletePkU128CallbackId(self.imp.on_reducer( "delete_pk_u128", - Box::new(move |ctx: &super::EventContext, args: &DeletePkU128| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePkU128 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_pk_u_128(&self, callback: DeletePkU128CallbackId) { - self.imp.remove_on_reducer::("delete_pk_u128", callback.0) + self.imp.remove_on_reducer("delete_pk_u128", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_16_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_16_reducer.rs index 6dc81e2a5e2..3acd5a072f3 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_16_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_16_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePkU16 { +pub(super) struct DeletePkU16Args { pub n: u16, } -impl __sdk::spacetime_module::InModule for DeletePkU16 { +impl From for super::Reducer { + fn from(args: DeletePkU16Args) -> Self { + Self::DeletePkU16 { n: args.n } + } +} + +impl __sdk::InModule for DeletePkU16Args { type Module = super::RemoteModule; } -pub struct DeletePkU16CallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePkU16CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_pk_u16`. @@ -52,19 +57,32 @@ pub trait delete_pk_u_16 { impl delete_pk_u_16 for super::RemoteReducers { fn delete_pk_u_16(&self, n: u16) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_pk_u16", DeletePkU16 { n }) + self.imp.call_reducer("delete_pk_u16", DeletePkU16Args { n }) } fn on_delete_pk_u_16( &self, mut callback: impl FnMut(&super::EventContext, &u16) + Send + 'static, ) -> DeletePkU16CallbackId { - DeletePkU16CallbackId(self.imp.on_reducer::( + DeletePkU16CallbackId(self.imp.on_reducer( "delete_pk_u16", - Box::new(move |ctx: &super::EventContext, args: &DeletePkU16| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePkU16 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_pk_u_16(&self, callback: DeletePkU16CallbackId) { - self.imp.remove_on_reducer::("delete_pk_u16", callback.0) + self.imp.remove_on_reducer("delete_pk_u16", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_256_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_256_reducer.rs index 295f70ba972..5f7d227495b 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_256_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_256_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePkU256 { +pub(super) struct DeletePkU256Args { pub n: __sats::u256, } -impl __sdk::spacetime_module::InModule for DeletePkU256 { +impl From for super::Reducer { + fn from(args: DeletePkU256Args) -> Self { + Self::DeletePkU256 { n: args.n } + } +} + +impl __sdk::InModule for DeletePkU256Args { type Module = super::RemoteModule; } -pub struct DeletePkU256CallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePkU256CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_pk_u256`. @@ -52,19 +57,32 @@ pub trait delete_pk_u_256 { impl delete_pk_u_256 for super::RemoteReducers { fn delete_pk_u_256(&self, n: __sats::u256) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_pk_u256", DeletePkU256 { n }) + self.imp.call_reducer("delete_pk_u256", DeletePkU256Args { n }) } fn on_delete_pk_u_256( &self, mut callback: impl FnMut(&super::EventContext, &__sats::u256) + Send + 'static, ) -> DeletePkU256CallbackId { - DeletePkU256CallbackId(self.imp.on_reducer::( + DeletePkU256CallbackId(self.imp.on_reducer( "delete_pk_u256", - Box::new(move |ctx: &super::EventContext, args: &DeletePkU256| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePkU256 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_pk_u_256(&self, callback: DeletePkU256CallbackId) { - self.imp.remove_on_reducer::("delete_pk_u256", callback.0) + self.imp.remove_on_reducer("delete_pk_u256", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_32_reducer.rs index d5f7b40a957..374e756f88b 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_32_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePkU32 { +pub(super) struct DeletePkU32Args { pub n: u32, } -impl __sdk::spacetime_module::InModule for DeletePkU32 { +impl From for super::Reducer { + fn from(args: DeletePkU32Args) -> Self { + Self::DeletePkU32 { n: args.n } + } +} + +impl __sdk::InModule for DeletePkU32Args { type Module = super::RemoteModule; } -pub struct DeletePkU32CallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePkU32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_pk_u32`. @@ -52,19 +57,32 @@ pub trait delete_pk_u_32 { impl delete_pk_u_32 for super::RemoteReducers { fn delete_pk_u_32(&self, n: u32) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_pk_u32", DeletePkU32 { n }) + self.imp.call_reducer("delete_pk_u32", DeletePkU32Args { n }) } fn on_delete_pk_u_32( &self, mut callback: impl FnMut(&super::EventContext, &u32) + Send + 'static, ) -> DeletePkU32CallbackId { - DeletePkU32CallbackId(self.imp.on_reducer::( + DeletePkU32CallbackId(self.imp.on_reducer( "delete_pk_u32", - Box::new(move |ctx: &super::EventContext, args: &DeletePkU32| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePkU32 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_pk_u_32(&self, callback: DeletePkU32CallbackId) { - self.imp.remove_on_reducer::("delete_pk_u32", callback.0) + self.imp.remove_on_reducer("delete_pk_u32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_64_reducer.rs index 33ab5fcc7dc..5fbe1323598 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_64_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePkU64 { +pub(super) struct DeletePkU64Args { pub n: u64, } -impl __sdk::spacetime_module::InModule for DeletePkU64 { +impl From for super::Reducer { + fn from(args: DeletePkU64Args) -> Self { + Self::DeletePkU64 { n: args.n } + } +} + +impl __sdk::InModule for DeletePkU64Args { type Module = super::RemoteModule; } -pub struct DeletePkU64CallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePkU64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_pk_u64`. @@ -52,19 +57,32 @@ pub trait delete_pk_u_64 { impl delete_pk_u_64 for super::RemoteReducers { fn delete_pk_u_64(&self, n: u64) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_pk_u64", DeletePkU64 { n }) + self.imp.call_reducer("delete_pk_u64", DeletePkU64Args { n }) } fn on_delete_pk_u_64( &self, mut callback: impl FnMut(&super::EventContext, &u64) + Send + 'static, ) -> DeletePkU64CallbackId { - DeletePkU64CallbackId(self.imp.on_reducer::( + DeletePkU64CallbackId(self.imp.on_reducer( "delete_pk_u64", - Box::new(move |ctx: &super::EventContext, args: &DeletePkU64| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePkU64 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_pk_u_64(&self, callback: DeletePkU64CallbackId) { - self.imp.remove_on_reducer::("delete_pk_u64", callback.0) + self.imp.remove_on_reducer("delete_pk_u64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_8_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_8_reducer.rs index 5962cec3438..de173bd2732 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_8_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_pk_u_8_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeletePkU8 { +pub(super) struct DeletePkU8Args { pub n: u8, } -impl __sdk::spacetime_module::InModule for DeletePkU8 { +impl From for super::Reducer { + fn from(args: DeletePkU8Args) -> Self { + Self::DeletePkU8 { n: args.n } + } +} + +impl __sdk::InModule for DeletePkU8Args { type Module = super::RemoteModule; } -pub struct DeletePkU8CallbackId(__sdk::callbacks::CallbackId); +pub struct DeletePkU8CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_pk_u8`. @@ -52,19 +57,32 @@ pub trait delete_pk_u_8 { impl delete_pk_u_8 for super::RemoteReducers { fn delete_pk_u_8(&self, n: u8) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_pk_u8", DeletePkU8 { n }) + self.imp.call_reducer("delete_pk_u8", DeletePkU8Args { n }) } fn on_delete_pk_u_8( &self, mut callback: impl FnMut(&super::EventContext, &u8) + Send + 'static, ) -> DeletePkU8CallbackId { - DeletePkU8CallbackId(self.imp.on_reducer::( + DeletePkU8CallbackId(self.imp.on_reducer( "delete_pk_u8", - Box::new(move |ctx: &super::EventContext, args: &DeletePkU8| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeletePkU8 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_pk_u_8(&self, callback: DeletePkU8CallbackId) { - self.imp.remove_on_reducer::("delete_pk_u8", callback.0) + self.imp.remove_on_reducer("delete_pk_u8", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_address_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_address_reducer.rs index c034849d2e4..ab58b4c7062 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_address_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_address_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeleteUniqueAddress { +pub(super) struct DeleteUniqueAddressArgs { pub a: __sdk::Address, } -impl __sdk::spacetime_module::InModule for DeleteUniqueAddress { +impl From for super::Reducer { + fn from(args: DeleteUniqueAddressArgs) -> Self { + Self::DeleteUniqueAddress { a: args.a } + } +} + +impl __sdk::InModule for DeleteUniqueAddressArgs { type Module = super::RemoteModule; } -pub struct DeleteUniqueAddressCallbackId(__sdk::callbacks::CallbackId); +pub struct DeleteUniqueAddressCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_unique_address`. @@ -53,20 +58,32 @@ pub trait delete_unique_address { impl delete_unique_address for super::RemoteReducers { fn delete_unique_address(&self, a: __sdk::Address) -> __anyhow::Result<()> { self.imp - .call_reducer("delete_unique_address", DeleteUniqueAddress { a }) + .call_reducer("delete_unique_address", DeleteUniqueAddressArgs { a }) } fn on_delete_unique_address( &self, mut callback: impl FnMut(&super::EventContext, &__sdk::Address) + Send + 'static, ) -> DeleteUniqueAddressCallbackId { - DeleteUniqueAddressCallbackId(self.imp.on_reducer::( + DeleteUniqueAddressCallbackId(self.imp.on_reducer( "delete_unique_address", - Box::new(move |ctx: &super::EventContext, args: &DeleteUniqueAddress| callback(ctx, &args.a)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeleteUniqueAddress { a }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, a) + }), )) } fn remove_on_delete_unique_address(&self, callback: DeleteUniqueAddressCallbackId) { - self.imp - .remove_on_reducer::("delete_unique_address", callback.0) + self.imp.remove_on_reducer("delete_unique_address", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_bool_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_bool_reducer.rs index eef5605b62b..a253967ebf9 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_bool_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_bool_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeleteUniqueBool { +pub(super) struct DeleteUniqueBoolArgs { pub b: bool, } -impl __sdk::spacetime_module::InModule for DeleteUniqueBool { +impl From for super::Reducer { + fn from(args: DeleteUniqueBoolArgs) -> Self { + Self::DeleteUniqueBool { b: args.b } + } +} + +impl __sdk::InModule for DeleteUniqueBoolArgs { type Module = super::RemoteModule; } -pub struct DeleteUniqueBoolCallbackId(__sdk::callbacks::CallbackId); +pub struct DeleteUniqueBoolCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_unique_bool`. @@ -52,20 +57,32 @@ pub trait delete_unique_bool { impl delete_unique_bool for super::RemoteReducers { fn delete_unique_bool(&self, b: bool) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_unique_bool", DeleteUniqueBool { b }) + self.imp.call_reducer("delete_unique_bool", DeleteUniqueBoolArgs { b }) } fn on_delete_unique_bool( &self, mut callback: impl FnMut(&super::EventContext, &bool) + Send + 'static, ) -> DeleteUniqueBoolCallbackId { - DeleteUniqueBoolCallbackId(self.imp.on_reducer::( + DeleteUniqueBoolCallbackId(self.imp.on_reducer( "delete_unique_bool", - Box::new(move |ctx: &super::EventContext, args: &DeleteUniqueBool| callback(ctx, &args.b)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeleteUniqueBool { b }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, b) + }), )) } fn remove_on_delete_unique_bool(&self, callback: DeleteUniqueBoolCallbackId) { - self.imp - .remove_on_reducer::("delete_unique_bool", callback.0) + self.imp.remove_on_reducer("delete_unique_bool", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_128_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_128_reducer.rs index 6f2950634b6..d0665f16250 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_128_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_128_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeleteUniqueI128 { +pub(super) struct DeleteUniqueI128Args { pub n: i128, } -impl __sdk::spacetime_module::InModule for DeleteUniqueI128 { +impl From for super::Reducer { + fn from(args: DeleteUniqueI128Args) -> Self { + Self::DeleteUniqueI128 { n: args.n } + } +} + +impl __sdk::InModule for DeleteUniqueI128Args { type Module = super::RemoteModule; } -pub struct DeleteUniqueI128CallbackId(__sdk::callbacks::CallbackId); +pub struct DeleteUniqueI128CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_unique_i128`. @@ -52,20 +57,32 @@ pub trait delete_unique_i_128 { impl delete_unique_i_128 for super::RemoteReducers { fn delete_unique_i_128(&self, n: i128) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_unique_i128", DeleteUniqueI128 { n }) + self.imp.call_reducer("delete_unique_i128", DeleteUniqueI128Args { n }) } fn on_delete_unique_i_128( &self, mut callback: impl FnMut(&super::EventContext, &i128) + Send + 'static, ) -> DeleteUniqueI128CallbackId { - DeleteUniqueI128CallbackId(self.imp.on_reducer::( + DeleteUniqueI128CallbackId(self.imp.on_reducer( "delete_unique_i128", - Box::new(move |ctx: &super::EventContext, args: &DeleteUniqueI128| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeleteUniqueI128 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_unique_i_128(&self, callback: DeleteUniqueI128CallbackId) { - self.imp - .remove_on_reducer::("delete_unique_i128", callback.0) + self.imp.remove_on_reducer("delete_unique_i128", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_16_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_16_reducer.rs index 0f08c5ec716..70dc6a7d010 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_16_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_16_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeleteUniqueI16 { +pub(super) struct DeleteUniqueI16Args { pub n: i16, } -impl __sdk::spacetime_module::InModule for DeleteUniqueI16 { +impl From for super::Reducer { + fn from(args: DeleteUniqueI16Args) -> Self { + Self::DeleteUniqueI16 { n: args.n } + } +} + +impl __sdk::InModule for DeleteUniqueI16Args { type Module = super::RemoteModule; } -pub struct DeleteUniqueI16CallbackId(__sdk::callbacks::CallbackId); +pub struct DeleteUniqueI16CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_unique_i16`. @@ -52,20 +57,32 @@ pub trait delete_unique_i_16 { impl delete_unique_i_16 for super::RemoteReducers { fn delete_unique_i_16(&self, n: i16) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_unique_i16", DeleteUniqueI16 { n }) + self.imp.call_reducer("delete_unique_i16", DeleteUniqueI16Args { n }) } fn on_delete_unique_i_16( &self, mut callback: impl FnMut(&super::EventContext, &i16) + Send + 'static, ) -> DeleteUniqueI16CallbackId { - DeleteUniqueI16CallbackId(self.imp.on_reducer::( + DeleteUniqueI16CallbackId(self.imp.on_reducer( "delete_unique_i16", - Box::new(move |ctx: &super::EventContext, args: &DeleteUniqueI16| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeleteUniqueI16 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_unique_i_16(&self, callback: DeleteUniqueI16CallbackId) { - self.imp - .remove_on_reducer::("delete_unique_i16", callback.0) + self.imp.remove_on_reducer("delete_unique_i16", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_256_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_256_reducer.rs index 4d20cf591fe..9f68fc8d61d 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_256_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_256_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeleteUniqueI256 { +pub(super) struct DeleteUniqueI256Args { pub n: __sats::i256, } -impl __sdk::spacetime_module::InModule for DeleteUniqueI256 { +impl From for super::Reducer { + fn from(args: DeleteUniqueI256Args) -> Self { + Self::DeleteUniqueI256 { n: args.n } + } +} + +impl __sdk::InModule for DeleteUniqueI256Args { type Module = super::RemoteModule; } -pub struct DeleteUniqueI256CallbackId(__sdk::callbacks::CallbackId); +pub struct DeleteUniqueI256CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_unique_i256`. @@ -52,20 +57,32 @@ pub trait delete_unique_i_256 { impl delete_unique_i_256 for super::RemoteReducers { fn delete_unique_i_256(&self, n: __sats::i256) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_unique_i256", DeleteUniqueI256 { n }) + self.imp.call_reducer("delete_unique_i256", DeleteUniqueI256Args { n }) } fn on_delete_unique_i_256( &self, mut callback: impl FnMut(&super::EventContext, &__sats::i256) + Send + 'static, ) -> DeleteUniqueI256CallbackId { - DeleteUniqueI256CallbackId(self.imp.on_reducer::( + DeleteUniqueI256CallbackId(self.imp.on_reducer( "delete_unique_i256", - Box::new(move |ctx: &super::EventContext, args: &DeleteUniqueI256| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeleteUniqueI256 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_unique_i_256(&self, callback: DeleteUniqueI256CallbackId) { - self.imp - .remove_on_reducer::("delete_unique_i256", callback.0) + self.imp.remove_on_reducer("delete_unique_i256", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_32_reducer.rs index 15bb9189ce9..d5560698d0d 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_32_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeleteUniqueI32 { +pub(super) struct DeleteUniqueI32Args { pub n: i32, } -impl __sdk::spacetime_module::InModule for DeleteUniqueI32 { +impl From for super::Reducer { + fn from(args: DeleteUniqueI32Args) -> Self { + Self::DeleteUniqueI32 { n: args.n } + } +} + +impl __sdk::InModule for DeleteUniqueI32Args { type Module = super::RemoteModule; } -pub struct DeleteUniqueI32CallbackId(__sdk::callbacks::CallbackId); +pub struct DeleteUniqueI32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_unique_i32`. @@ -52,20 +57,32 @@ pub trait delete_unique_i_32 { impl delete_unique_i_32 for super::RemoteReducers { fn delete_unique_i_32(&self, n: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_unique_i32", DeleteUniqueI32 { n }) + self.imp.call_reducer("delete_unique_i32", DeleteUniqueI32Args { n }) } fn on_delete_unique_i_32( &self, mut callback: impl FnMut(&super::EventContext, &i32) + Send + 'static, ) -> DeleteUniqueI32CallbackId { - DeleteUniqueI32CallbackId(self.imp.on_reducer::( + DeleteUniqueI32CallbackId(self.imp.on_reducer( "delete_unique_i32", - Box::new(move |ctx: &super::EventContext, args: &DeleteUniqueI32| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeleteUniqueI32 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_unique_i_32(&self, callback: DeleteUniqueI32CallbackId) { - self.imp - .remove_on_reducer::("delete_unique_i32", callback.0) + self.imp.remove_on_reducer("delete_unique_i32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_64_reducer.rs index 7f72627391e..73f959eebd0 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_64_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeleteUniqueI64 { +pub(super) struct DeleteUniqueI64Args { pub n: i64, } -impl __sdk::spacetime_module::InModule for DeleteUniqueI64 { +impl From for super::Reducer { + fn from(args: DeleteUniqueI64Args) -> Self { + Self::DeleteUniqueI64 { n: args.n } + } +} + +impl __sdk::InModule for DeleteUniqueI64Args { type Module = super::RemoteModule; } -pub struct DeleteUniqueI64CallbackId(__sdk::callbacks::CallbackId); +pub struct DeleteUniqueI64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_unique_i64`. @@ -52,20 +57,32 @@ pub trait delete_unique_i_64 { impl delete_unique_i_64 for super::RemoteReducers { fn delete_unique_i_64(&self, n: i64) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_unique_i64", DeleteUniqueI64 { n }) + self.imp.call_reducer("delete_unique_i64", DeleteUniqueI64Args { n }) } fn on_delete_unique_i_64( &self, mut callback: impl FnMut(&super::EventContext, &i64) + Send + 'static, ) -> DeleteUniqueI64CallbackId { - DeleteUniqueI64CallbackId(self.imp.on_reducer::( + DeleteUniqueI64CallbackId(self.imp.on_reducer( "delete_unique_i64", - Box::new(move |ctx: &super::EventContext, args: &DeleteUniqueI64| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeleteUniqueI64 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_unique_i_64(&self, callback: DeleteUniqueI64CallbackId) { - self.imp - .remove_on_reducer::("delete_unique_i64", callback.0) + self.imp.remove_on_reducer("delete_unique_i64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_8_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_8_reducer.rs index 030be737cfa..7bc97006af3 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_8_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_i_8_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeleteUniqueI8 { +pub(super) struct DeleteUniqueI8Args { pub n: i8, } -impl __sdk::spacetime_module::InModule for DeleteUniqueI8 { +impl From for super::Reducer { + fn from(args: DeleteUniqueI8Args) -> Self { + Self::DeleteUniqueI8 { n: args.n } + } +} + +impl __sdk::InModule for DeleteUniqueI8Args { type Module = super::RemoteModule; } -pub struct DeleteUniqueI8CallbackId(__sdk::callbacks::CallbackId); +pub struct DeleteUniqueI8CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_unique_i8`. @@ -52,20 +57,32 @@ pub trait delete_unique_i_8 { impl delete_unique_i_8 for super::RemoteReducers { fn delete_unique_i_8(&self, n: i8) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_unique_i8", DeleteUniqueI8 { n }) + self.imp.call_reducer("delete_unique_i8", DeleteUniqueI8Args { n }) } fn on_delete_unique_i_8( &self, mut callback: impl FnMut(&super::EventContext, &i8) + Send + 'static, ) -> DeleteUniqueI8CallbackId { - DeleteUniqueI8CallbackId(self.imp.on_reducer::( + DeleteUniqueI8CallbackId(self.imp.on_reducer( "delete_unique_i8", - Box::new(move |ctx: &super::EventContext, args: &DeleteUniqueI8| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeleteUniqueI8 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_unique_i_8(&self, callback: DeleteUniqueI8CallbackId) { - self.imp - .remove_on_reducer::("delete_unique_i8", callback.0) + self.imp.remove_on_reducer("delete_unique_i8", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_identity_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_identity_reducer.rs index 19ce7967f93..758a08aef8f 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_identity_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_identity_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeleteUniqueIdentity { +pub(super) struct DeleteUniqueIdentityArgs { pub i: __sdk::Identity, } -impl __sdk::spacetime_module::InModule for DeleteUniqueIdentity { +impl From for super::Reducer { + fn from(args: DeleteUniqueIdentityArgs) -> Self { + Self::DeleteUniqueIdentity { i: args.i } + } +} + +impl __sdk::InModule for DeleteUniqueIdentityArgs { type Module = super::RemoteModule; } -pub struct DeleteUniqueIdentityCallbackId(__sdk::callbacks::CallbackId); +pub struct DeleteUniqueIdentityCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_unique_identity`. @@ -53,20 +58,32 @@ pub trait delete_unique_identity { impl delete_unique_identity for super::RemoteReducers { fn delete_unique_identity(&self, i: __sdk::Identity) -> __anyhow::Result<()> { self.imp - .call_reducer("delete_unique_identity", DeleteUniqueIdentity { i }) + .call_reducer("delete_unique_identity", DeleteUniqueIdentityArgs { i }) } fn on_delete_unique_identity( &self, mut callback: impl FnMut(&super::EventContext, &__sdk::Identity) + Send + 'static, ) -> DeleteUniqueIdentityCallbackId { - DeleteUniqueIdentityCallbackId(self.imp.on_reducer::( + DeleteUniqueIdentityCallbackId(self.imp.on_reducer( "delete_unique_identity", - Box::new(move |ctx: &super::EventContext, args: &DeleteUniqueIdentity| callback(ctx, &args.i)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeleteUniqueIdentity { i }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, i) + }), )) } fn remove_on_delete_unique_identity(&self, callback: DeleteUniqueIdentityCallbackId) { - self.imp - .remove_on_reducer::("delete_unique_identity", callback.0) + self.imp.remove_on_reducer("delete_unique_identity", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_string_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_string_reducer.rs index 997aa914e58..948c8b1dbf6 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_string_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_string_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeleteUniqueString { +pub(super) struct DeleteUniqueStringArgs { pub s: String, } -impl __sdk::spacetime_module::InModule for DeleteUniqueString { +impl From for super::Reducer { + fn from(args: DeleteUniqueStringArgs) -> Self { + Self::DeleteUniqueString { s: args.s } + } +} + +impl __sdk::InModule for DeleteUniqueStringArgs { type Module = super::RemoteModule; } -pub struct DeleteUniqueStringCallbackId(__sdk::callbacks::CallbackId); +pub struct DeleteUniqueStringCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_unique_string`. @@ -52,20 +57,33 @@ pub trait delete_unique_string { impl delete_unique_string for super::RemoteReducers { fn delete_unique_string(&self, s: String) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_unique_string", DeleteUniqueString { s }) + self.imp + .call_reducer("delete_unique_string", DeleteUniqueStringArgs { s }) } fn on_delete_unique_string( &self, mut callback: impl FnMut(&super::EventContext, &String) + Send + 'static, ) -> DeleteUniqueStringCallbackId { - DeleteUniqueStringCallbackId(self.imp.on_reducer::( + DeleteUniqueStringCallbackId(self.imp.on_reducer( "delete_unique_string", - Box::new(move |ctx: &super::EventContext, args: &DeleteUniqueString| callback(ctx, &args.s)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeleteUniqueString { s }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s) + }), )) } fn remove_on_delete_unique_string(&self, callback: DeleteUniqueStringCallbackId) { - self.imp - .remove_on_reducer::("delete_unique_string", callback.0) + self.imp.remove_on_reducer("delete_unique_string", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_128_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_128_reducer.rs index d4878402c7f..ca7df9c9ac3 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_128_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_128_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeleteUniqueU128 { +pub(super) struct DeleteUniqueU128Args { pub n: u128, } -impl __sdk::spacetime_module::InModule for DeleteUniqueU128 { +impl From for super::Reducer { + fn from(args: DeleteUniqueU128Args) -> Self { + Self::DeleteUniqueU128 { n: args.n } + } +} + +impl __sdk::InModule for DeleteUniqueU128Args { type Module = super::RemoteModule; } -pub struct DeleteUniqueU128CallbackId(__sdk::callbacks::CallbackId); +pub struct DeleteUniqueU128CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_unique_u128`. @@ -52,20 +57,32 @@ pub trait delete_unique_u_128 { impl delete_unique_u_128 for super::RemoteReducers { fn delete_unique_u_128(&self, n: u128) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_unique_u128", DeleteUniqueU128 { n }) + self.imp.call_reducer("delete_unique_u128", DeleteUniqueU128Args { n }) } fn on_delete_unique_u_128( &self, mut callback: impl FnMut(&super::EventContext, &u128) + Send + 'static, ) -> DeleteUniqueU128CallbackId { - DeleteUniqueU128CallbackId(self.imp.on_reducer::( + DeleteUniqueU128CallbackId(self.imp.on_reducer( "delete_unique_u128", - Box::new(move |ctx: &super::EventContext, args: &DeleteUniqueU128| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeleteUniqueU128 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_unique_u_128(&self, callback: DeleteUniqueU128CallbackId) { - self.imp - .remove_on_reducer::("delete_unique_u128", callback.0) + self.imp.remove_on_reducer("delete_unique_u128", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_16_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_16_reducer.rs index 362ab6334da..a100b5cfb2d 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_16_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_16_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeleteUniqueU16 { +pub(super) struct DeleteUniqueU16Args { pub n: u16, } -impl __sdk::spacetime_module::InModule for DeleteUniqueU16 { +impl From for super::Reducer { + fn from(args: DeleteUniqueU16Args) -> Self { + Self::DeleteUniqueU16 { n: args.n } + } +} + +impl __sdk::InModule for DeleteUniqueU16Args { type Module = super::RemoteModule; } -pub struct DeleteUniqueU16CallbackId(__sdk::callbacks::CallbackId); +pub struct DeleteUniqueU16CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_unique_u16`. @@ -52,20 +57,32 @@ pub trait delete_unique_u_16 { impl delete_unique_u_16 for super::RemoteReducers { fn delete_unique_u_16(&self, n: u16) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_unique_u16", DeleteUniqueU16 { n }) + self.imp.call_reducer("delete_unique_u16", DeleteUniqueU16Args { n }) } fn on_delete_unique_u_16( &self, mut callback: impl FnMut(&super::EventContext, &u16) + Send + 'static, ) -> DeleteUniqueU16CallbackId { - DeleteUniqueU16CallbackId(self.imp.on_reducer::( + DeleteUniqueU16CallbackId(self.imp.on_reducer( "delete_unique_u16", - Box::new(move |ctx: &super::EventContext, args: &DeleteUniqueU16| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeleteUniqueU16 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_unique_u_16(&self, callback: DeleteUniqueU16CallbackId) { - self.imp - .remove_on_reducer::("delete_unique_u16", callback.0) + self.imp.remove_on_reducer("delete_unique_u16", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_256_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_256_reducer.rs index 7be56298065..06b1872f966 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_256_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_256_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeleteUniqueU256 { +pub(super) struct DeleteUniqueU256Args { pub n: __sats::u256, } -impl __sdk::spacetime_module::InModule for DeleteUniqueU256 { +impl From for super::Reducer { + fn from(args: DeleteUniqueU256Args) -> Self { + Self::DeleteUniqueU256 { n: args.n } + } +} + +impl __sdk::InModule for DeleteUniqueU256Args { type Module = super::RemoteModule; } -pub struct DeleteUniqueU256CallbackId(__sdk::callbacks::CallbackId); +pub struct DeleteUniqueU256CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_unique_u256`. @@ -52,20 +57,32 @@ pub trait delete_unique_u_256 { impl delete_unique_u_256 for super::RemoteReducers { fn delete_unique_u_256(&self, n: __sats::u256) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_unique_u256", DeleteUniqueU256 { n }) + self.imp.call_reducer("delete_unique_u256", DeleteUniqueU256Args { n }) } fn on_delete_unique_u_256( &self, mut callback: impl FnMut(&super::EventContext, &__sats::u256) + Send + 'static, ) -> DeleteUniqueU256CallbackId { - DeleteUniqueU256CallbackId(self.imp.on_reducer::( + DeleteUniqueU256CallbackId(self.imp.on_reducer( "delete_unique_u256", - Box::new(move |ctx: &super::EventContext, args: &DeleteUniqueU256| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeleteUniqueU256 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_unique_u_256(&self, callback: DeleteUniqueU256CallbackId) { - self.imp - .remove_on_reducer::("delete_unique_u256", callback.0) + self.imp.remove_on_reducer("delete_unique_u256", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_32_reducer.rs index 25a845bb27c..4361cf5b709 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_32_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeleteUniqueU32 { +pub(super) struct DeleteUniqueU32Args { pub n: u32, } -impl __sdk::spacetime_module::InModule for DeleteUniqueU32 { +impl From for super::Reducer { + fn from(args: DeleteUniqueU32Args) -> Self { + Self::DeleteUniqueU32 { n: args.n } + } +} + +impl __sdk::InModule for DeleteUniqueU32Args { type Module = super::RemoteModule; } -pub struct DeleteUniqueU32CallbackId(__sdk::callbacks::CallbackId); +pub struct DeleteUniqueU32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_unique_u32`. @@ -52,20 +57,32 @@ pub trait delete_unique_u_32 { impl delete_unique_u_32 for super::RemoteReducers { fn delete_unique_u_32(&self, n: u32) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_unique_u32", DeleteUniqueU32 { n }) + self.imp.call_reducer("delete_unique_u32", DeleteUniqueU32Args { n }) } fn on_delete_unique_u_32( &self, mut callback: impl FnMut(&super::EventContext, &u32) + Send + 'static, ) -> DeleteUniqueU32CallbackId { - DeleteUniqueU32CallbackId(self.imp.on_reducer::( + DeleteUniqueU32CallbackId(self.imp.on_reducer( "delete_unique_u32", - Box::new(move |ctx: &super::EventContext, args: &DeleteUniqueU32| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeleteUniqueU32 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_unique_u_32(&self, callback: DeleteUniqueU32CallbackId) { - self.imp - .remove_on_reducer::("delete_unique_u32", callback.0) + self.imp.remove_on_reducer("delete_unique_u32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_64_reducer.rs index 51ef5443bb6..c27b2c51bb6 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_64_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeleteUniqueU64 { +pub(super) struct DeleteUniqueU64Args { pub n: u64, } -impl __sdk::spacetime_module::InModule for DeleteUniqueU64 { +impl From for super::Reducer { + fn from(args: DeleteUniqueU64Args) -> Self { + Self::DeleteUniqueU64 { n: args.n } + } +} + +impl __sdk::InModule for DeleteUniqueU64Args { type Module = super::RemoteModule; } -pub struct DeleteUniqueU64CallbackId(__sdk::callbacks::CallbackId); +pub struct DeleteUniqueU64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_unique_u64`. @@ -52,20 +57,32 @@ pub trait delete_unique_u_64 { impl delete_unique_u_64 for super::RemoteReducers { fn delete_unique_u_64(&self, n: u64) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_unique_u64", DeleteUniqueU64 { n }) + self.imp.call_reducer("delete_unique_u64", DeleteUniqueU64Args { n }) } fn on_delete_unique_u_64( &self, mut callback: impl FnMut(&super::EventContext, &u64) + Send + 'static, ) -> DeleteUniqueU64CallbackId { - DeleteUniqueU64CallbackId(self.imp.on_reducer::( + DeleteUniqueU64CallbackId(self.imp.on_reducer( "delete_unique_u64", - Box::new(move |ctx: &super::EventContext, args: &DeleteUniqueU64| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeleteUniqueU64 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_unique_u_64(&self, callback: DeleteUniqueU64CallbackId) { - self.imp - .remove_on_reducer::("delete_unique_u64", callback.0) + self.imp.remove_on_reducer("delete_unique_u64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_8_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_8_reducer.rs index 7673e5e1569..fd692c260f9 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_8_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/delete_unique_u_8_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DeleteUniqueU8 { +pub(super) struct DeleteUniqueU8Args { pub n: u8, } -impl __sdk::spacetime_module::InModule for DeleteUniqueU8 { +impl From for super::Reducer { + fn from(args: DeleteUniqueU8Args) -> Self { + Self::DeleteUniqueU8 { n: args.n } + } +} + +impl __sdk::InModule for DeleteUniqueU8Args { type Module = super::RemoteModule; } -pub struct DeleteUniqueU8CallbackId(__sdk::callbacks::CallbackId); +pub struct DeleteUniqueU8CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `delete_unique_u8`. @@ -52,20 +57,32 @@ pub trait delete_unique_u_8 { impl delete_unique_u_8 for super::RemoteReducers { fn delete_unique_u_8(&self, n: u8) -> __anyhow::Result<()> { - self.imp.call_reducer("delete_unique_u8", DeleteUniqueU8 { n }) + self.imp.call_reducer("delete_unique_u8", DeleteUniqueU8Args { n }) } fn on_delete_unique_u_8( &self, mut callback: impl FnMut(&super::EventContext, &u8) + Send + 'static, ) -> DeleteUniqueU8CallbackId { - DeleteUniqueU8CallbackId(self.imp.on_reducer::( + DeleteUniqueU8CallbackId(self.imp.on_reducer( "delete_unique_u8", - Box::new(move |ctx: &super::EventContext, args: &DeleteUniqueU8| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::DeleteUniqueU8 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_delete_unique_u_8(&self, callback: DeleteUniqueU8CallbackId) { - self.imp - .remove_on_reducer::("delete_unique_u8", callback.0) + self.imp.remove_on_reducer("delete_unique_u8", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/enum_with_payload_type.rs b/crates/sdk/tests/test-client/src/module_bindings/enum_with_payload_type.rs index b974ab7e31a..3bcfec4fb99 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/enum_with_payload_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/enum_with_payload_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::simple_enum_type::SimpleEnum; @@ -58,6 +57,6 @@ pub enum EnumWithPayload { SimpleEnums(Vec), } -impl __sdk::spacetime_module::InModule for EnumWithPayload { +impl __sdk::InModule for EnumWithPayload { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/every_primitive_struct_type.rs b/crates/sdk/tests/test-client/src/module_bindings/every_primitive_struct_type.rs index 49726187e62..932e13e20e5 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/every_primitive_struct_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/every_primitive_struct_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -31,6 +30,6 @@ pub struct EveryPrimitiveStruct { pub r: __sdk::Address, } -impl __sdk::spacetime_module::InModule for EveryPrimitiveStruct { +impl __sdk::InModule for EveryPrimitiveStruct { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/every_vec_struct_type.rs b/crates/sdk/tests/test-client/src/module_bindings/every_vec_struct_type.rs index d9d02a5f14a..cd373b7112f 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/every_vec_struct_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/every_vec_struct_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -31,6 +30,6 @@ pub struct EveryVecStruct { pub r: Vec<__sdk::Address>, } -impl __sdk::spacetime_module::InModule for EveryVecStruct { +impl __sdk::InModule for EveryVecStruct { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/indexed_table_2_table.rs b/crates/sdk/tests/test-client/src/module_bindings/indexed_table_2_table.rs new file mode 100644 index 00000000000..1fa90b9aab6 --- /dev/null +++ b/crates/sdk/tests/test-client/src/module_bindings/indexed_table_2_table.rs @@ -0,0 +1,94 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. + +#![allow(unused)] +use super::indexed_table_2_type::IndexedTable2; +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, + anyhow::{self as __anyhow, Context as _}, +}; + +/// Table handle for the table `indexed_table_2`. +/// +/// Obtain a handle from the [`IndexedTable2TableAccess::indexed_table_2`] method on [`super::RemoteTables`], +/// like `ctx.db.indexed_table_2()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.indexed_table_2().on_insert(...)`. +pub struct IndexedTable2TableHandle<'ctx> { + imp: __sdk::TableHandle, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `indexed_table_2`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait IndexedTable2TableAccess { + #[allow(non_snake_case)] + /// Obtain a [`IndexedTable2TableHandle`], which mediates access to the table `indexed_table_2`. + fn indexed_table_2(&self) -> IndexedTable2TableHandle<'_>; +} + +impl IndexedTable2TableAccess for super::RemoteTables { + fn indexed_table_2(&self) -> IndexedTable2TableHandle<'_> { + IndexedTable2TableHandle { + imp: self.imp.get_table::("indexed_table_2"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct IndexedTable2InsertCallbackId(__sdk::CallbackId); +pub struct IndexedTable2DeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for IndexedTable2TableHandle<'ctx> { + type Row = IndexedTable2; + type EventContext = super::EventContext; + + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } + + type InsertCallbackId = IndexedTable2InsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> IndexedTable2InsertCallbackId { + IndexedTable2InsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: IndexedTable2InsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = IndexedTable2DeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> IndexedTable2DeleteCallbackId { + IndexedTable2DeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: IndexedTable2DeleteCallbackId) { + self.imp.remove_on_delete(callback.0) + } +} + +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("indexed_table_2"); +} +#[doc(hidden)] +pub(super) fn parse_table_update( + raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) + .context("Failed to parse table update for table \"indexed_table_2\"") +} diff --git a/crates/sdk/tests/test-client/src/module_bindings/indexed_table_2_type.rs b/crates/sdk/tests/test-client/src/module_bindings/indexed_table_2_type.rs new file mode 100644 index 00000000000..ffcb7ba9cd9 --- /dev/null +++ b/crates/sdk/tests/test-client/src/module_bindings/indexed_table_2_type.rs @@ -0,0 +1,19 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. + +#![allow(unused)] +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, + anyhow::{self as __anyhow, Context as _}, +}; + +#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] +#[sats(crate = __lib)] +pub struct IndexedTable2 { + pub player_id: u32, + pub player_snazz: f32, +} + +impl __sdk::InModule for IndexedTable2 { + type Module = super::RemoteModule; +} diff --git a/crates/sdk/tests/test-client/src/module_bindings/indexed_table_table.rs b/crates/sdk/tests/test-client/src/module_bindings/indexed_table_table.rs new file mode 100644 index 00000000000..2e5e209fec8 --- /dev/null +++ b/crates/sdk/tests/test-client/src/module_bindings/indexed_table_table.rs @@ -0,0 +1,94 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. + +#![allow(unused)] +use super::indexed_table_type::IndexedTable; +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, + anyhow::{self as __anyhow, Context as _}, +}; + +/// Table handle for the table `indexed_table`. +/// +/// Obtain a handle from the [`IndexedTableTableAccess::indexed_table`] method on [`super::RemoteTables`], +/// like `ctx.db.indexed_table()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.indexed_table().on_insert(...)`. +pub struct IndexedTableTableHandle<'ctx> { + imp: __sdk::TableHandle, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `indexed_table`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait IndexedTableTableAccess { + #[allow(non_snake_case)] + /// Obtain a [`IndexedTableTableHandle`], which mediates access to the table `indexed_table`. + fn indexed_table(&self) -> IndexedTableTableHandle<'_>; +} + +impl IndexedTableTableAccess for super::RemoteTables { + fn indexed_table(&self) -> IndexedTableTableHandle<'_> { + IndexedTableTableHandle { + imp: self.imp.get_table::("indexed_table"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct IndexedTableInsertCallbackId(__sdk::CallbackId); +pub struct IndexedTableDeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for IndexedTableTableHandle<'ctx> { + type Row = IndexedTable; + type EventContext = super::EventContext; + + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } + + type InsertCallbackId = IndexedTableInsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> IndexedTableInsertCallbackId { + IndexedTableInsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: IndexedTableInsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = IndexedTableDeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> IndexedTableDeleteCallbackId { + IndexedTableDeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: IndexedTableDeleteCallbackId) { + self.imp.remove_on_delete(callback.0) + } +} + +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("indexed_table"); +} +#[doc(hidden)] +pub(super) fn parse_table_update( + raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) + .context("Failed to parse table update for table \"indexed_table\"") +} diff --git a/crates/sdk/tests/test-client/src/module_bindings/indexed_table_type.rs b/crates/sdk/tests/test-client/src/module_bindings/indexed_table_type.rs new file mode 100644 index 00000000000..91e70cc981c --- /dev/null +++ b/crates/sdk/tests/test-client/src/module_bindings/indexed_table_type.rs @@ -0,0 +1,18 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. + +#![allow(unused)] +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, + anyhow::{self as __anyhow, Context as _}, +}; + +#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] +#[sats(crate = __lib)] +pub struct IndexedTable { + pub player_id: u32, +} + +impl __sdk::InModule for IndexedTable { + type Module = super::RemoteModule; +} diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_caller_one_address_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_caller_one_address_reducer.rs index a3f0cda63bd..5adc7f39d64 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_caller_one_address_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_caller_one_address_reducer.rs @@ -2,21 +2,26 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertCallerOneAddress {} +pub(super) struct InsertCallerOneAddressArgs {} -impl __sdk::spacetime_module::InModule for InsertCallerOneAddress { +impl From for super::Reducer { + fn from(args: InsertCallerOneAddressArgs) -> Self { + Self::InsertCallerOneAddress + } +} + +impl __sdk::InModule for InsertCallerOneAddressArgs { type Module = super::RemoteModule; } -pub struct InsertCallerOneAddressCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertCallerOneAddressCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_caller_one_address`. @@ -51,20 +56,32 @@ pub trait insert_caller_one_address { impl insert_caller_one_address for super::RemoteReducers { fn insert_caller_one_address(&self) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_caller_one_address", InsertCallerOneAddress {}) + .call_reducer("insert_caller_one_address", InsertCallerOneAddressArgs {}) } fn on_insert_caller_one_address( &self, mut callback: impl FnMut(&super::EventContext) + Send + 'static, ) -> InsertCallerOneAddressCallbackId { - InsertCallerOneAddressCallbackId(self.imp.on_reducer::( + InsertCallerOneAddressCallbackId(self.imp.on_reducer( "insert_caller_one_address", - Box::new(move |ctx: &super::EventContext, args: &InsertCallerOneAddress| callback(ctx)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertCallerOneAddress {}, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx) + }), )) } fn remove_on_insert_caller_one_address(&self, callback: InsertCallerOneAddressCallbackId) { - self.imp - .remove_on_reducer::("insert_caller_one_address", callback.0) + self.imp.remove_on_reducer("insert_caller_one_address", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_caller_one_identity_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_caller_one_identity_reducer.rs index 7a518a6d7fc..1e8cfc2aae6 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_caller_one_identity_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_caller_one_identity_reducer.rs @@ -2,21 +2,26 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertCallerOneIdentity {} +pub(super) struct InsertCallerOneIdentityArgs {} -impl __sdk::spacetime_module::InModule for InsertCallerOneIdentity { +impl From for super::Reducer { + fn from(args: InsertCallerOneIdentityArgs) -> Self { + Self::InsertCallerOneIdentity + } +} + +impl __sdk::InModule for InsertCallerOneIdentityArgs { type Module = super::RemoteModule; } -pub struct InsertCallerOneIdentityCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertCallerOneIdentityCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_caller_one_identity`. @@ -51,20 +56,32 @@ pub trait insert_caller_one_identity { impl insert_caller_one_identity for super::RemoteReducers { fn insert_caller_one_identity(&self) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_caller_one_identity", InsertCallerOneIdentity {}) + .call_reducer("insert_caller_one_identity", InsertCallerOneIdentityArgs {}) } fn on_insert_caller_one_identity( &self, mut callback: impl FnMut(&super::EventContext) + Send + 'static, ) -> InsertCallerOneIdentityCallbackId { - InsertCallerOneIdentityCallbackId(self.imp.on_reducer::( + InsertCallerOneIdentityCallbackId(self.imp.on_reducer( "insert_caller_one_identity", - Box::new(move |ctx: &super::EventContext, args: &InsertCallerOneIdentity| callback(ctx)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertCallerOneIdentity {}, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx) + }), )) } fn remove_on_insert_caller_one_identity(&self, callback: InsertCallerOneIdentityCallbackId) { - self.imp - .remove_on_reducer::("insert_caller_one_identity", callback.0) + self.imp.remove_on_reducer("insert_caller_one_identity", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_caller_pk_address_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_caller_pk_address_reducer.rs index 14ba0ce94da..a96ce8ceec8 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_caller_pk_address_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_caller_pk_address_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertCallerPkAddress { +pub(super) struct InsertCallerPkAddressArgs { pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertCallerPkAddress { +impl From for super::Reducer { + fn from(args: InsertCallerPkAddressArgs) -> Self { + Self::InsertCallerPkAddress { data: args.data } + } +} + +impl __sdk::InModule for InsertCallerPkAddressArgs { type Module = super::RemoteModule; } -pub struct InsertCallerPkAddressCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertCallerPkAddressCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_caller_pk_address`. @@ -53,20 +58,32 @@ pub trait insert_caller_pk_address { impl insert_caller_pk_address for super::RemoteReducers { fn insert_caller_pk_address(&self, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_caller_pk_address", InsertCallerPkAddress { data }) + .call_reducer("insert_caller_pk_address", InsertCallerPkAddressArgs { data }) } fn on_insert_caller_pk_address( &self, mut callback: impl FnMut(&super::EventContext, &i32) + Send + 'static, ) -> InsertCallerPkAddressCallbackId { - InsertCallerPkAddressCallbackId(self.imp.on_reducer::( + InsertCallerPkAddressCallbackId(self.imp.on_reducer( "insert_caller_pk_address", - Box::new(move |ctx: &super::EventContext, args: &InsertCallerPkAddress| callback(ctx, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertCallerPkAddress { data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, data) + }), )) } fn remove_on_insert_caller_pk_address(&self, callback: InsertCallerPkAddressCallbackId) { - self.imp - .remove_on_reducer::("insert_caller_pk_address", callback.0) + self.imp.remove_on_reducer("insert_caller_pk_address", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_caller_pk_identity_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_caller_pk_identity_reducer.rs index 6cd10d4e3a1..cb01efde175 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_caller_pk_identity_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_caller_pk_identity_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertCallerPkIdentity { +pub(super) struct InsertCallerPkIdentityArgs { pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertCallerPkIdentity { +impl From for super::Reducer { + fn from(args: InsertCallerPkIdentityArgs) -> Self { + Self::InsertCallerPkIdentity { data: args.data } + } +} + +impl __sdk::InModule for InsertCallerPkIdentityArgs { type Module = super::RemoteModule; } -pub struct InsertCallerPkIdentityCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertCallerPkIdentityCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_caller_pk_identity`. @@ -53,20 +58,32 @@ pub trait insert_caller_pk_identity { impl insert_caller_pk_identity for super::RemoteReducers { fn insert_caller_pk_identity(&self, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_caller_pk_identity", InsertCallerPkIdentity { data }) + .call_reducer("insert_caller_pk_identity", InsertCallerPkIdentityArgs { data }) } fn on_insert_caller_pk_identity( &self, mut callback: impl FnMut(&super::EventContext, &i32) + Send + 'static, ) -> InsertCallerPkIdentityCallbackId { - InsertCallerPkIdentityCallbackId(self.imp.on_reducer::( + InsertCallerPkIdentityCallbackId(self.imp.on_reducer( "insert_caller_pk_identity", - Box::new(move |ctx: &super::EventContext, args: &InsertCallerPkIdentity| callback(ctx, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertCallerPkIdentity { data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, data) + }), )) } fn remove_on_insert_caller_pk_identity(&self, callback: InsertCallerPkIdentityCallbackId) { - self.imp - .remove_on_reducer::("insert_caller_pk_identity", callback.0) + self.imp.remove_on_reducer("insert_caller_pk_identity", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_caller_unique_address_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_caller_unique_address_reducer.rs index 61f5f2bcdfb..af19b55d52f 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_caller_unique_address_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_caller_unique_address_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertCallerUniqueAddress { +pub(super) struct InsertCallerUniqueAddressArgs { pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertCallerUniqueAddress { +impl From for super::Reducer { + fn from(args: InsertCallerUniqueAddressArgs) -> Self { + Self::InsertCallerUniqueAddress { data: args.data } + } +} + +impl __sdk::InModule for InsertCallerUniqueAddressArgs { type Module = super::RemoteModule; } -pub struct InsertCallerUniqueAddressCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertCallerUniqueAddressCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_caller_unique_address`. @@ -53,20 +58,32 @@ pub trait insert_caller_unique_address { impl insert_caller_unique_address for super::RemoteReducers { fn insert_caller_unique_address(&self, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_caller_unique_address", InsertCallerUniqueAddress { data }) + .call_reducer("insert_caller_unique_address", InsertCallerUniqueAddressArgs { data }) } fn on_insert_caller_unique_address( &self, mut callback: impl FnMut(&super::EventContext, &i32) + Send + 'static, ) -> InsertCallerUniqueAddressCallbackId { - InsertCallerUniqueAddressCallbackId(self.imp.on_reducer::( + InsertCallerUniqueAddressCallbackId(self.imp.on_reducer( "insert_caller_unique_address", - Box::new(move |ctx: &super::EventContext, args: &InsertCallerUniqueAddress| callback(ctx, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertCallerUniqueAddress { data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, data) + }), )) } fn remove_on_insert_caller_unique_address(&self, callback: InsertCallerUniqueAddressCallbackId) { - self.imp - .remove_on_reducer::("insert_caller_unique_address", callback.0) + self.imp.remove_on_reducer("insert_caller_unique_address", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_caller_unique_identity_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_caller_unique_identity_reducer.rs index 98fae641f9a..dd0631421dc 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_caller_unique_identity_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_caller_unique_identity_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertCallerUniqueIdentity { +pub(super) struct InsertCallerUniqueIdentityArgs { pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertCallerUniqueIdentity { +impl From for super::Reducer { + fn from(args: InsertCallerUniqueIdentityArgs) -> Self { + Self::InsertCallerUniqueIdentity { data: args.data } + } +} + +impl __sdk::InModule for InsertCallerUniqueIdentityArgs { type Module = super::RemoteModule; } -pub struct InsertCallerUniqueIdentityCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertCallerUniqueIdentityCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_caller_unique_identity`. @@ -53,20 +58,32 @@ pub trait insert_caller_unique_identity { impl insert_caller_unique_identity for super::RemoteReducers { fn insert_caller_unique_identity(&self, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_caller_unique_identity", InsertCallerUniqueIdentity { data }) + .call_reducer("insert_caller_unique_identity", InsertCallerUniqueIdentityArgs { data }) } fn on_insert_caller_unique_identity( &self, mut callback: impl FnMut(&super::EventContext, &i32) + Send + 'static, ) -> InsertCallerUniqueIdentityCallbackId { - InsertCallerUniqueIdentityCallbackId(self.imp.on_reducer::( + InsertCallerUniqueIdentityCallbackId(self.imp.on_reducer( "insert_caller_unique_identity", - Box::new(move |ctx: &super::EventContext, args: &InsertCallerUniqueIdentity| callback(ctx, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertCallerUniqueIdentity { data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, data) + }), )) } fn remove_on_insert_caller_unique_identity(&self, callback: InsertCallerUniqueIdentityCallbackId) { - self.imp - .remove_on_reducer::("insert_caller_unique_identity", callback.0) + self.imp.remove_on_reducer("insert_caller_unique_identity", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_caller_vec_address_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_caller_vec_address_reducer.rs index c564d3dcd34..ca065f2621e 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_caller_vec_address_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_caller_vec_address_reducer.rs @@ -2,21 +2,26 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertCallerVecAddress {} +pub(super) struct InsertCallerVecAddressArgs {} -impl __sdk::spacetime_module::InModule for InsertCallerVecAddress { +impl From for super::Reducer { + fn from(args: InsertCallerVecAddressArgs) -> Self { + Self::InsertCallerVecAddress + } +} + +impl __sdk::InModule for InsertCallerVecAddressArgs { type Module = super::RemoteModule; } -pub struct InsertCallerVecAddressCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertCallerVecAddressCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_caller_vec_address`. @@ -51,20 +56,32 @@ pub trait insert_caller_vec_address { impl insert_caller_vec_address for super::RemoteReducers { fn insert_caller_vec_address(&self) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_caller_vec_address", InsertCallerVecAddress {}) + .call_reducer("insert_caller_vec_address", InsertCallerVecAddressArgs {}) } fn on_insert_caller_vec_address( &self, mut callback: impl FnMut(&super::EventContext) + Send + 'static, ) -> InsertCallerVecAddressCallbackId { - InsertCallerVecAddressCallbackId(self.imp.on_reducer::( + InsertCallerVecAddressCallbackId(self.imp.on_reducer( "insert_caller_vec_address", - Box::new(move |ctx: &super::EventContext, args: &InsertCallerVecAddress| callback(ctx)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertCallerVecAddress {}, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx) + }), )) } fn remove_on_insert_caller_vec_address(&self, callback: InsertCallerVecAddressCallbackId) { - self.imp - .remove_on_reducer::("insert_caller_vec_address", callback.0) + self.imp.remove_on_reducer("insert_caller_vec_address", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_caller_vec_identity_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_caller_vec_identity_reducer.rs index a343cd78e1e..5632e867751 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_caller_vec_identity_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_caller_vec_identity_reducer.rs @@ -2,21 +2,26 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertCallerVecIdentity {} +pub(super) struct InsertCallerVecIdentityArgs {} -impl __sdk::spacetime_module::InModule for InsertCallerVecIdentity { +impl From for super::Reducer { + fn from(args: InsertCallerVecIdentityArgs) -> Self { + Self::InsertCallerVecIdentity + } +} + +impl __sdk::InModule for InsertCallerVecIdentityArgs { type Module = super::RemoteModule; } -pub struct InsertCallerVecIdentityCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertCallerVecIdentityCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_caller_vec_identity`. @@ -51,20 +56,32 @@ pub trait insert_caller_vec_identity { impl insert_caller_vec_identity for super::RemoteReducers { fn insert_caller_vec_identity(&self) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_caller_vec_identity", InsertCallerVecIdentity {}) + .call_reducer("insert_caller_vec_identity", InsertCallerVecIdentityArgs {}) } fn on_insert_caller_vec_identity( &self, mut callback: impl FnMut(&super::EventContext) + Send + 'static, ) -> InsertCallerVecIdentityCallbackId { - InsertCallerVecIdentityCallbackId(self.imp.on_reducer::( + InsertCallerVecIdentityCallbackId(self.imp.on_reducer( "insert_caller_vec_identity", - Box::new(move |ctx: &super::EventContext, args: &InsertCallerVecIdentity| callback(ctx)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertCallerVecIdentity {}, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx) + }), )) } fn remove_on_insert_caller_vec_identity(&self, callback: InsertCallerVecIdentityCallbackId) { - self.imp - .remove_on_reducer::("insert_caller_vec_identity", callback.0) + self.imp.remove_on_reducer("insert_caller_vec_identity", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_large_table_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_large_table_reducer.rs index ed171b244ce..8344dabaf9f 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_large_table_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_large_table_reducer.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::byte_struct_type::ByteStruct; @@ -17,7 +16,7 @@ use super::unit_struct_type::UnitStruct; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertLargeTable { +pub(super) struct InsertLargeTableArgs { pub a: u8, pub b: u16, pub c: u32, @@ -42,11 +41,40 @@ pub struct InsertLargeTable { pub v: EveryVecStruct, } -impl __sdk::spacetime_module::InModule for InsertLargeTable { +impl From for super::Reducer { + fn from(args: InsertLargeTableArgs) -> Self { + Self::InsertLargeTable { + a: args.a, + b: args.b, + c: args.c, + d: args.d, + e: args.e, + f: args.f, + g: args.g, + h: args.h, + i: args.i, + j: args.j, + k: args.k, + l: args.l, + m: args.m, + n: args.n, + o: args.o, + p: args.p, + q: args.q, + r: args.r, + s: args.s, + t: args.t, + u: args.u, + v: args.v, + } + } +} + +impl __sdk::InModule for InsertLargeTableArgs { type Module = super::RemoteModule; } -pub struct InsertLargeTableCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertLargeTableCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_large_table`. @@ -155,7 +183,7 @@ impl insert_large_table for super::RemoteReducers { ) -> __anyhow::Result<()> { self.imp.call_reducer( "insert_large_table", - InsertLargeTable { + InsertLargeTableArgs { a, b, c, @@ -210,20 +238,50 @@ impl insert_large_table for super::RemoteReducers { ) + Send + 'static, ) -> InsertLargeTableCallbackId { - InsertLargeTableCallbackId(self.imp.on_reducer::( + InsertLargeTableCallbackId(self.imp.on_reducer( "insert_large_table", - Box::new(move |ctx: &super::EventContext, args: &InsertLargeTable| { - callback( - ctx, &args.a, &args.b, &args.c, &args.d, &args.e, &args.f, &args.g, &args.h, &args.i, &args.j, - &args.k, &args.l, &args.m, &args.n, &args.o, &args.p, &args.q, &args.r, &args.s, &args.t, &args.u, - &args.v, - ) + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: + super::Reducer::InsertLargeTable { + a, + b, + c, + d, + e, + f, + g, + h, + i, + j, + k, + l, + m, + n, + o, + p, + q, + r, + s, + t, + u, + v, + }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) }), )) } fn remove_on_insert_large_table(&self, callback: InsertLargeTableCallbackId) { - self.imp - .remove_on_reducer::("insert_large_table", callback.0) + self.imp.remove_on_reducer("insert_large_table", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_address_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_address_reducer.rs index dae46ab9e7d..0b6ea59567e 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_address_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_address_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneAddress { +pub(super) struct InsertOneAddressArgs { pub a: __sdk::Address, } -impl __sdk::spacetime_module::InModule for InsertOneAddress { +impl From for super::Reducer { + fn from(args: InsertOneAddressArgs) -> Self { + Self::InsertOneAddress { a: args.a } + } +} + +impl __sdk::InModule for InsertOneAddressArgs { type Module = super::RemoteModule; } -pub struct InsertOneAddressCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneAddressCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_address`. @@ -52,20 +57,32 @@ pub trait insert_one_address { impl insert_one_address for super::RemoteReducers { fn insert_one_address(&self, a: __sdk::Address) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_address", InsertOneAddress { a }) + self.imp.call_reducer("insert_one_address", InsertOneAddressArgs { a }) } fn on_insert_one_address( &self, mut callback: impl FnMut(&super::EventContext, &__sdk::Address) + Send + 'static, ) -> InsertOneAddressCallbackId { - InsertOneAddressCallbackId(self.imp.on_reducer::( + InsertOneAddressCallbackId(self.imp.on_reducer( "insert_one_address", - Box::new(move |ctx: &super::EventContext, args: &InsertOneAddress| callback(ctx, &args.a)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneAddress { a }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, a) + }), )) } fn remove_on_insert_one_address(&self, callback: InsertOneAddressCallbackId) { - self.imp - .remove_on_reducer::("insert_one_address", callback.0) + self.imp.remove_on_reducer("insert_one_address", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_bool_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_bool_reducer.rs index e934f5b5162..7dc95379512 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_bool_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_bool_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneBool { +pub(super) struct InsertOneBoolArgs { pub b: bool, } -impl __sdk::spacetime_module::InModule for InsertOneBool { +impl From for super::Reducer { + fn from(args: InsertOneBoolArgs) -> Self { + Self::InsertOneBool { b: args.b } + } +} + +impl __sdk::InModule for InsertOneBoolArgs { type Module = super::RemoteModule; } -pub struct InsertOneBoolCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneBoolCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_bool`. @@ -52,20 +57,32 @@ pub trait insert_one_bool { impl insert_one_bool for super::RemoteReducers { fn insert_one_bool(&self, b: bool) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_bool", InsertOneBool { b }) + self.imp.call_reducer("insert_one_bool", InsertOneBoolArgs { b }) } fn on_insert_one_bool( &self, mut callback: impl FnMut(&super::EventContext, &bool) + Send + 'static, ) -> InsertOneBoolCallbackId { - InsertOneBoolCallbackId(self.imp.on_reducer::( + InsertOneBoolCallbackId(self.imp.on_reducer( "insert_one_bool", - Box::new(move |ctx: &super::EventContext, args: &InsertOneBool| callback(ctx, &args.b)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneBool { b }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, b) + }), )) } fn remove_on_insert_one_bool(&self, callback: InsertOneBoolCallbackId) { - self.imp - .remove_on_reducer::("insert_one_bool", callback.0) + self.imp.remove_on_reducer("insert_one_bool", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_byte_struct_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_byte_struct_reducer.rs index fd56ecace5f..95fa6daf166 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_byte_struct_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_byte_struct_reducer.rs @@ -2,25 +2,30 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::byte_struct_type::ByteStruct; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneByteStruct { +pub(super) struct InsertOneByteStructArgs { pub s: ByteStruct, } -impl __sdk::spacetime_module::InModule for InsertOneByteStruct { +impl From for super::Reducer { + fn from(args: InsertOneByteStructArgs) -> Self { + Self::InsertOneByteStruct { s: args.s } + } +} + +impl __sdk::InModule for InsertOneByteStructArgs { type Module = super::RemoteModule; } -pub struct InsertOneByteStructCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneByteStructCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_byte_struct`. @@ -55,20 +60,32 @@ pub trait insert_one_byte_struct { impl insert_one_byte_struct for super::RemoteReducers { fn insert_one_byte_struct(&self, s: ByteStruct) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_one_byte_struct", InsertOneByteStruct { s }) + .call_reducer("insert_one_byte_struct", InsertOneByteStructArgs { s }) } fn on_insert_one_byte_struct( &self, mut callback: impl FnMut(&super::EventContext, &ByteStruct) + Send + 'static, ) -> InsertOneByteStructCallbackId { - InsertOneByteStructCallbackId(self.imp.on_reducer::( + InsertOneByteStructCallbackId(self.imp.on_reducer( "insert_one_byte_struct", - Box::new(move |ctx: &super::EventContext, args: &InsertOneByteStruct| callback(ctx, &args.s)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneByteStruct { s }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s) + }), )) } fn remove_on_insert_one_byte_struct(&self, callback: InsertOneByteStructCallbackId) { - self.imp - .remove_on_reducer::("insert_one_byte_struct", callback.0) + self.imp.remove_on_reducer("insert_one_byte_struct", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_enum_with_payload_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_enum_with_payload_reducer.rs index 16436743c93..2ff5a054ea3 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_enum_with_payload_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_enum_with_payload_reducer.rs @@ -2,25 +2,30 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::enum_with_payload_type::EnumWithPayload; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneEnumWithPayload { +pub(super) struct InsertOneEnumWithPayloadArgs { pub e: EnumWithPayload, } -impl __sdk::spacetime_module::InModule for InsertOneEnumWithPayload { +impl From for super::Reducer { + fn from(args: InsertOneEnumWithPayloadArgs) -> Self { + Self::InsertOneEnumWithPayload { e: args.e } + } +} + +impl __sdk::InModule for InsertOneEnumWithPayloadArgs { type Module = super::RemoteModule; } -pub struct InsertOneEnumWithPayloadCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneEnumWithPayloadCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_enum_with_payload`. @@ -55,20 +60,32 @@ pub trait insert_one_enum_with_payload { impl insert_one_enum_with_payload for super::RemoteReducers { fn insert_one_enum_with_payload(&self, e: EnumWithPayload) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_one_enum_with_payload", InsertOneEnumWithPayload { e }) + .call_reducer("insert_one_enum_with_payload", InsertOneEnumWithPayloadArgs { e }) } fn on_insert_one_enum_with_payload( &self, mut callback: impl FnMut(&super::EventContext, &EnumWithPayload) + Send + 'static, ) -> InsertOneEnumWithPayloadCallbackId { - InsertOneEnumWithPayloadCallbackId(self.imp.on_reducer::( + InsertOneEnumWithPayloadCallbackId(self.imp.on_reducer( "insert_one_enum_with_payload", - Box::new(move |ctx: &super::EventContext, args: &InsertOneEnumWithPayload| callback(ctx, &args.e)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneEnumWithPayload { e }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, e) + }), )) } fn remove_on_insert_one_enum_with_payload(&self, callback: InsertOneEnumWithPayloadCallbackId) { - self.imp - .remove_on_reducer::("insert_one_enum_with_payload", callback.0) + self.imp.remove_on_reducer("insert_one_enum_with_payload", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_every_primitive_struct_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_every_primitive_struct_reducer.rs index 32b97f36733..d59c4712a29 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_every_primitive_struct_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_every_primitive_struct_reducer.rs @@ -2,25 +2,30 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::every_primitive_struct_type::EveryPrimitiveStruct; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneEveryPrimitiveStruct { +pub(super) struct InsertOneEveryPrimitiveStructArgs { pub s: EveryPrimitiveStruct, } -impl __sdk::spacetime_module::InModule for InsertOneEveryPrimitiveStruct { +impl From for super::Reducer { + fn from(args: InsertOneEveryPrimitiveStructArgs) -> Self { + Self::InsertOneEveryPrimitiveStruct { s: args.s } + } +} + +impl __sdk::InModule for InsertOneEveryPrimitiveStructArgs { type Module = super::RemoteModule; } -pub struct InsertOneEveryPrimitiveStructCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneEveryPrimitiveStructCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_every_primitive_struct`. @@ -54,21 +59,36 @@ pub trait insert_one_every_primitive_struct { impl insert_one_every_primitive_struct for super::RemoteReducers { fn insert_one_every_primitive_struct(&self, s: EveryPrimitiveStruct) -> __anyhow::Result<()> { - self.imp - .call_reducer("insert_one_every_primitive_struct", InsertOneEveryPrimitiveStruct { s }) + self.imp.call_reducer( + "insert_one_every_primitive_struct", + InsertOneEveryPrimitiveStructArgs { s }, + ) } fn on_insert_one_every_primitive_struct( &self, mut callback: impl FnMut(&super::EventContext, &EveryPrimitiveStruct) + Send + 'static, ) -> InsertOneEveryPrimitiveStructCallbackId { - InsertOneEveryPrimitiveStructCallbackId(self.imp.on_reducer::( + InsertOneEveryPrimitiveStructCallbackId(self.imp.on_reducer( "insert_one_every_primitive_struct", - Box::new(move |ctx: &super::EventContext, args: &InsertOneEveryPrimitiveStruct| callback(ctx, &args.s)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneEveryPrimitiveStruct { s }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s) + }), )) } fn remove_on_insert_one_every_primitive_struct(&self, callback: InsertOneEveryPrimitiveStructCallbackId) { self.imp - .remove_on_reducer::("insert_one_every_primitive_struct", callback.0) + .remove_on_reducer("insert_one_every_primitive_struct", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_every_vec_struct_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_every_vec_struct_reducer.rs index 67bdda007d0..a42943b15a0 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_every_vec_struct_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_every_vec_struct_reducer.rs @@ -2,25 +2,30 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::every_vec_struct_type::EveryVecStruct; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneEveryVecStruct { +pub(super) struct InsertOneEveryVecStructArgs { pub s: EveryVecStruct, } -impl __sdk::spacetime_module::InModule for InsertOneEveryVecStruct { +impl From for super::Reducer { + fn from(args: InsertOneEveryVecStructArgs) -> Self { + Self::InsertOneEveryVecStruct { s: args.s } + } +} + +impl __sdk::InModule for InsertOneEveryVecStructArgs { type Module = super::RemoteModule; } -pub struct InsertOneEveryVecStructCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneEveryVecStructCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_every_vec_struct`. @@ -55,20 +60,32 @@ pub trait insert_one_every_vec_struct { impl insert_one_every_vec_struct for super::RemoteReducers { fn insert_one_every_vec_struct(&self, s: EveryVecStruct) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_one_every_vec_struct", InsertOneEveryVecStruct { s }) + .call_reducer("insert_one_every_vec_struct", InsertOneEveryVecStructArgs { s }) } fn on_insert_one_every_vec_struct( &self, mut callback: impl FnMut(&super::EventContext, &EveryVecStruct) + Send + 'static, ) -> InsertOneEveryVecStructCallbackId { - InsertOneEveryVecStructCallbackId(self.imp.on_reducer::( + InsertOneEveryVecStructCallbackId(self.imp.on_reducer( "insert_one_every_vec_struct", - Box::new(move |ctx: &super::EventContext, args: &InsertOneEveryVecStruct| callback(ctx, &args.s)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneEveryVecStruct { s }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s) + }), )) } fn remove_on_insert_one_every_vec_struct(&self, callback: InsertOneEveryVecStructCallbackId) { - self.imp - .remove_on_reducer::("insert_one_every_vec_struct", callback.0) + self.imp.remove_on_reducer("insert_one_every_vec_struct", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_f_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_f_32_reducer.rs index 693e9905bd4..db81c7680f6 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_f_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_f_32_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneF32 { +pub(super) struct InsertOneF32Args { pub f: f32, } -impl __sdk::spacetime_module::InModule for InsertOneF32 { +impl From for super::Reducer { + fn from(args: InsertOneF32Args) -> Self { + Self::InsertOneF32 { f: args.f } + } +} + +impl __sdk::InModule for InsertOneF32Args { type Module = super::RemoteModule; } -pub struct InsertOneF32CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneF32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_f32`. @@ -52,19 +57,32 @@ pub trait insert_one_f_32 { impl insert_one_f_32 for super::RemoteReducers { fn insert_one_f_32(&self, f: f32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_f32", InsertOneF32 { f }) + self.imp.call_reducer("insert_one_f32", InsertOneF32Args { f }) } fn on_insert_one_f_32( &self, mut callback: impl FnMut(&super::EventContext, &f32) + Send + 'static, ) -> InsertOneF32CallbackId { - InsertOneF32CallbackId(self.imp.on_reducer::( + InsertOneF32CallbackId(self.imp.on_reducer( "insert_one_f32", - Box::new(move |ctx: &super::EventContext, args: &InsertOneF32| callback(ctx, &args.f)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneF32 { f }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, f) + }), )) } fn remove_on_insert_one_f_32(&self, callback: InsertOneF32CallbackId) { - self.imp.remove_on_reducer::("insert_one_f32", callback.0) + self.imp.remove_on_reducer("insert_one_f32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_f_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_f_64_reducer.rs index 40cfdc0a563..9f55c024afb 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_f_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_f_64_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneF64 { +pub(super) struct InsertOneF64Args { pub f: f64, } -impl __sdk::spacetime_module::InModule for InsertOneF64 { +impl From for super::Reducer { + fn from(args: InsertOneF64Args) -> Self { + Self::InsertOneF64 { f: args.f } + } +} + +impl __sdk::InModule for InsertOneF64Args { type Module = super::RemoteModule; } -pub struct InsertOneF64CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneF64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_f64`. @@ -52,19 +57,32 @@ pub trait insert_one_f_64 { impl insert_one_f_64 for super::RemoteReducers { fn insert_one_f_64(&self, f: f64) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_f64", InsertOneF64 { f }) + self.imp.call_reducer("insert_one_f64", InsertOneF64Args { f }) } fn on_insert_one_f_64( &self, mut callback: impl FnMut(&super::EventContext, &f64) + Send + 'static, ) -> InsertOneF64CallbackId { - InsertOneF64CallbackId(self.imp.on_reducer::( + InsertOneF64CallbackId(self.imp.on_reducer( "insert_one_f64", - Box::new(move |ctx: &super::EventContext, args: &InsertOneF64| callback(ctx, &args.f)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneF64 { f }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, f) + }), )) } fn remove_on_insert_one_f_64(&self, callback: InsertOneF64CallbackId) { - self.imp.remove_on_reducer::("insert_one_f64", callback.0) + self.imp.remove_on_reducer("insert_one_f64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_128_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_128_reducer.rs index baf515e6ae3..5a0838c6379 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_128_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_128_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneI128 { +pub(super) struct InsertOneI128Args { pub n: i128, } -impl __sdk::spacetime_module::InModule for InsertOneI128 { +impl From for super::Reducer { + fn from(args: InsertOneI128Args) -> Self { + Self::InsertOneI128 { n: args.n } + } +} + +impl __sdk::InModule for InsertOneI128Args { type Module = super::RemoteModule; } -pub struct InsertOneI128CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneI128CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_i128`. @@ -52,20 +57,32 @@ pub trait insert_one_i_128 { impl insert_one_i_128 for super::RemoteReducers { fn insert_one_i_128(&self, n: i128) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_i128", InsertOneI128 { n }) + self.imp.call_reducer("insert_one_i128", InsertOneI128Args { n }) } fn on_insert_one_i_128( &self, mut callback: impl FnMut(&super::EventContext, &i128) + Send + 'static, ) -> InsertOneI128CallbackId { - InsertOneI128CallbackId(self.imp.on_reducer::( + InsertOneI128CallbackId(self.imp.on_reducer( "insert_one_i128", - Box::new(move |ctx: &super::EventContext, args: &InsertOneI128| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneI128 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_one_i_128(&self, callback: InsertOneI128CallbackId) { - self.imp - .remove_on_reducer::("insert_one_i128", callback.0) + self.imp.remove_on_reducer("insert_one_i128", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_16_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_16_reducer.rs index e8deffd28bc..17da31961b0 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_16_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_16_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneI16 { +pub(super) struct InsertOneI16Args { pub n: i16, } -impl __sdk::spacetime_module::InModule for InsertOneI16 { +impl From for super::Reducer { + fn from(args: InsertOneI16Args) -> Self { + Self::InsertOneI16 { n: args.n } + } +} + +impl __sdk::InModule for InsertOneI16Args { type Module = super::RemoteModule; } -pub struct InsertOneI16CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneI16CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_i16`. @@ -52,19 +57,32 @@ pub trait insert_one_i_16 { impl insert_one_i_16 for super::RemoteReducers { fn insert_one_i_16(&self, n: i16) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_i16", InsertOneI16 { n }) + self.imp.call_reducer("insert_one_i16", InsertOneI16Args { n }) } fn on_insert_one_i_16( &self, mut callback: impl FnMut(&super::EventContext, &i16) + Send + 'static, ) -> InsertOneI16CallbackId { - InsertOneI16CallbackId(self.imp.on_reducer::( + InsertOneI16CallbackId(self.imp.on_reducer( "insert_one_i16", - Box::new(move |ctx: &super::EventContext, args: &InsertOneI16| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneI16 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_one_i_16(&self, callback: InsertOneI16CallbackId) { - self.imp.remove_on_reducer::("insert_one_i16", callback.0) + self.imp.remove_on_reducer("insert_one_i16", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_256_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_256_reducer.rs index 6195af58bae..877858eb0b4 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_256_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_256_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneI256 { +pub(super) struct InsertOneI256Args { pub n: __sats::i256, } -impl __sdk::spacetime_module::InModule for InsertOneI256 { +impl From for super::Reducer { + fn from(args: InsertOneI256Args) -> Self { + Self::InsertOneI256 { n: args.n } + } +} + +impl __sdk::InModule for InsertOneI256Args { type Module = super::RemoteModule; } -pub struct InsertOneI256CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneI256CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_i256`. @@ -52,20 +57,32 @@ pub trait insert_one_i_256 { impl insert_one_i_256 for super::RemoteReducers { fn insert_one_i_256(&self, n: __sats::i256) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_i256", InsertOneI256 { n }) + self.imp.call_reducer("insert_one_i256", InsertOneI256Args { n }) } fn on_insert_one_i_256( &self, mut callback: impl FnMut(&super::EventContext, &__sats::i256) + Send + 'static, ) -> InsertOneI256CallbackId { - InsertOneI256CallbackId(self.imp.on_reducer::( + InsertOneI256CallbackId(self.imp.on_reducer( "insert_one_i256", - Box::new(move |ctx: &super::EventContext, args: &InsertOneI256| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneI256 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_one_i_256(&self, callback: InsertOneI256CallbackId) { - self.imp - .remove_on_reducer::("insert_one_i256", callback.0) + self.imp.remove_on_reducer("insert_one_i256", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_32_reducer.rs index 617a70112c2..12ddc0eb4ef 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_32_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneI32 { +pub(super) struct InsertOneI32Args { pub n: i32, } -impl __sdk::spacetime_module::InModule for InsertOneI32 { +impl From for super::Reducer { + fn from(args: InsertOneI32Args) -> Self { + Self::InsertOneI32 { n: args.n } + } +} + +impl __sdk::InModule for InsertOneI32Args { type Module = super::RemoteModule; } -pub struct InsertOneI32CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneI32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_i32`. @@ -52,19 +57,32 @@ pub trait insert_one_i_32 { impl insert_one_i_32 for super::RemoteReducers { fn insert_one_i_32(&self, n: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_i32", InsertOneI32 { n }) + self.imp.call_reducer("insert_one_i32", InsertOneI32Args { n }) } fn on_insert_one_i_32( &self, mut callback: impl FnMut(&super::EventContext, &i32) + Send + 'static, ) -> InsertOneI32CallbackId { - InsertOneI32CallbackId(self.imp.on_reducer::( + InsertOneI32CallbackId(self.imp.on_reducer( "insert_one_i32", - Box::new(move |ctx: &super::EventContext, args: &InsertOneI32| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneI32 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_one_i_32(&self, callback: InsertOneI32CallbackId) { - self.imp.remove_on_reducer::("insert_one_i32", callback.0) + self.imp.remove_on_reducer("insert_one_i32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_64_reducer.rs index 228d17b3e1e..61e4866d99e 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_64_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneI64 { +pub(super) struct InsertOneI64Args { pub n: i64, } -impl __sdk::spacetime_module::InModule for InsertOneI64 { +impl From for super::Reducer { + fn from(args: InsertOneI64Args) -> Self { + Self::InsertOneI64 { n: args.n } + } +} + +impl __sdk::InModule for InsertOneI64Args { type Module = super::RemoteModule; } -pub struct InsertOneI64CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneI64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_i64`. @@ -52,19 +57,32 @@ pub trait insert_one_i_64 { impl insert_one_i_64 for super::RemoteReducers { fn insert_one_i_64(&self, n: i64) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_i64", InsertOneI64 { n }) + self.imp.call_reducer("insert_one_i64", InsertOneI64Args { n }) } fn on_insert_one_i_64( &self, mut callback: impl FnMut(&super::EventContext, &i64) + Send + 'static, ) -> InsertOneI64CallbackId { - InsertOneI64CallbackId(self.imp.on_reducer::( + InsertOneI64CallbackId(self.imp.on_reducer( "insert_one_i64", - Box::new(move |ctx: &super::EventContext, args: &InsertOneI64| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneI64 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_one_i_64(&self, callback: InsertOneI64CallbackId) { - self.imp.remove_on_reducer::("insert_one_i64", callback.0) + self.imp.remove_on_reducer("insert_one_i64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_8_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_8_reducer.rs index 520732e7907..7dab4a81084 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_8_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_i_8_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneI8 { +pub(super) struct InsertOneI8Args { pub n: i8, } -impl __sdk::spacetime_module::InModule for InsertOneI8 { +impl From for super::Reducer { + fn from(args: InsertOneI8Args) -> Self { + Self::InsertOneI8 { n: args.n } + } +} + +impl __sdk::InModule for InsertOneI8Args { type Module = super::RemoteModule; } -pub struct InsertOneI8CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneI8CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_i8`. @@ -52,19 +57,32 @@ pub trait insert_one_i_8 { impl insert_one_i_8 for super::RemoteReducers { fn insert_one_i_8(&self, n: i8) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_i8", InsertOneI8 { n }) + self.imp.call_reducer("insert_one_i8", InsertOneI8Args { n }) } fn on_insert_one_i_8( &self, mut callback: impl FnMut(&super::EventContext, &i8) + Send + 'static, ) -> InsertOneI8CallbackId { - InsertOneI8CallbackId(self.imp.on_reducer::( + InsertOneI8CallbackId(self.imp.on_reducer( "insert_one_i8", - Box::new(move |ctx: &super::EventContext, args: &InsertOneI8| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneI8 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_one_i_8(&self, callback: InsertOneI8CallbackId) { - self.imp.remove_on_reducer::("insert_one_i8", callback.0) + self.imp.remove_on_reducer("insert_one_i8", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_identity_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_identity_reducer.rs index 647f7e2bfa8..8b155949d2a 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_identity_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_identity_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneIdentity { +pub(super) struct InsertOneIdentityArgs { pub i: __sdk::Identity, } -impl __sdk::spacetime_module::InModule for InsertOneIdentity { +impl From for super::Reducer { + fn from(args: InsertOneIdentityArgs) -> Self { + Self::InsertOneIdentity { i: args.i } + } +} + +impl __sdk::InModule for InsertOneIdentityArgs { type Module = super::RemoteModule; } -pub struct InsertOneIdentityCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneIdentityCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_identity`. @@ -52,20 +57,33 @@ pub trait insert_one_identity { impl insert_one_identity for super::RemoteReducers { fn insert_one_identity(&self, i: __sdk::Identity) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_identity", InsertOneIdentity { i }) + self.imp + .call_reducer("insert_one_identity", InsertOneIdentityArgs { i }) } fn on_insert_one_identity( &self, mut callback: impl FnMut(&super::EventContext, &__sdk::Identity) + Send + 'static, ) -> InsertOneIdentityCallbackId { - InsertOneIdentityCallbackId(self.imp.on_reducer::( + InsertOneIdentityCallbackId(self.imp.on_reducer( "insert_one_identity", - Box::new(move |ctx: &super::EventContext, args: &InsertOneIdentity| callback(ctx, &args.i)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneIdentity { i }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, i) + }), )) } fn remove_on_insert_one_identity(&self, callback: InsertOneIdentityCallbackId) { - self.imp - .remove_on_reducer::("insert_one_identity", callback.0) + self.imp.remove_on_reducer("insert_one_identity", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_simple_enum_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_simple_enum_reducer.rs index 3ece98fb8e5..424f723d296 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_simple_enum_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_simple_enum_reducer.rs @@ -2,25 +2,30 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::simple_enum_type::SimpleEnum; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneSimpleEnum { +pub(super) struct InsertOneSimpleEnumArgs { pub e: SimpleEnum, } -impl __sdk::spacetime_module::InModule for InsertOneSimpleEnum { +impl From for super::Reducer { + fn from(args: InsertOneSimpleEnumArgs) -> Self { + Self::InsertOneSimpleEnum { e: args.e } + } +} + +impl __sdk::InModule for InsertOneSimpleEnumArgs { type Module = super::RemoteModule; } -pub struct InsertOneSimpleEnumCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneSimpleEnumCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_simple_enum`. @@ -55,20 +60,32 @@ pub trait insert_one_simple_enum { impl insert_one_simple_enum for super::RemoteReducers { fn insert_one_simple_enum(&self, e: SimpleEnum) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_one_simple_enum", InsertOneSimpleEnum { e }) + .call_reducer("insert_one_simple_enum", InsertOneSimpleEnumArgs { e }) } fn on_insert_one_simple_enum( &self, mut callback: impl FnMut(&super::EventContext, &SimpleEnum) + Send + 'static, ) -> InsertOneSimpleEnumCallbackId { - InsertOneSimpleEnumCallbackId(self.imp.on_reducer::( + InsertOneSimpleEnumCallbackId(self.imp.on_reducer( "insert_one_simple_enum", - Box::new(move |ctx: &super::EventContext, args: &InsertOneSimpleEnum| callback(ctx, &args.e)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneSimpleEnum { e }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, e) + }), )) } fn remove_on_insert_one_simple_enum(&self, callback: InsertOneSimpleEnumCallbackId) { - self.imp - .remove_on_reducer::("insert_one_simple_enum", callback.0) + self.imp.remove_on_reducer("insert_one_simple_enum", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_string_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_string_reducer.rs index 7606e406d28..76fd9fead67 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_string_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_string_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneString { +pub(super) struct InsertOneStringArgs { pub s: String, } -impl __sdk::spacetime_module::InModule for InsertOneString { +impl From for super::Reducer { + fn from(args: InsertOneStringArgs) -> Self { + Self::InsertOneString { s: args.s } + } +} + +impl __sdk::InModule for InsertOneStringArgs { type Module = super::RemoteModule; } -pub struct InsertOneStringCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneStringCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_string`. @@ -52,20 +57,32 @@ pub trait insert_one_string { impl insert_one_string for super::RemoteReducers { fn insert_one_string(&self, s: String) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_string", InsertOneString { s }) + self.imp.call_reducer("insert_one_string", InsertOneStringArgs { s }) } fn on_insert_one_string( &self, mut callback: impl FnMut(&super::EventContext, &String) + Send + 'static, ) -> InsertOneStringCallbackId { - InsertOneStringCallbackId(self.imp.on_reducer::( + InsertOneStringCallbackId(self.imp.on_reducer( "insert_one_string", - Box::new(move |ctx: &super::EventContext, args: &InsertOneString| callback(ctx, &args.s)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneString { s }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s) + }), )) } fn remove_on_insert_one_string(&self, callback: InsertOneStringCallbackId) { - self.imp - .remove_on_reducer::("insert_one_string", callback.0) + self.imp.remove_on_reducer("insert_one_string", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_128_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_128_reducer.rs index d63f011747b..c7dd6695b8b 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_128_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_128_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneU128 { +pub(super) struct InsertOneU128Args { pub n: u128, } -impl __sdk::spacetime_module::InModule for InsertOneU128 { +impl From for super::Reducer { + fn from(args: InsertOneU128Args) -> Self { + Self::InsertOneU128 { n: args.n } + } +} + +impl __sdk::InModule for InsertOneU128Args { type Module = super::RemoteModule; } -pub struct InsertOneU128CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneU128CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_u128`. @@ -52,20 +57,32 @@ pub trait insert_one_u_128 { impl insert_one_u_128 for super::RemoteReducers { fn insert_one_u_128(&self, n: u128) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_u128", InsertOneU128 { n }) + self.imp.call_reducer("insert_one_u128", InsertOneU128Args { n }) } fn on_insert_one_u_128( &self, mut callback: impl FnMut(&super::EventContext, &u128) + Send + 'static, ) -> InsertOneU128CallbackId { - InsertOneU128CallbackId(self.imp.on_reducer::( + InsertOneU128CallbackId(self.imp.on_reducer( "insert_one_u128", - Box::new(move |ctx: &super::EventContext, args: &InsertOneU128| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneU128 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_one_u_128(&self, callback: InsertOneU128CallbackId) { - self.imp - .remove_on_reducer::("insert_one_u128", callback.0) + self.imp.remove_on_reducer("insert_one_u128", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_16_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_16_reducer.rs index dd1155f2f47..751072cdae4 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_16_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_16_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneU16 { +pub(super) struct InsertOneU16Args { pub n: u16, } -impl __sdk::spacetime_module::InModule for InsertOneU16 { +impl From for super::Reducer { + fn from(args: InsertOneU16Args) -> Self { + Self::InsertOneU16 { n: args.n } + } +} + +impl __sdk::InModule for InsertOneU16Args { type Module = super::RemoteModule; } -pub struct InsertOneU16CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneU16CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_u16`. @@ -52,19 +57,32 @@ pub trait insert_one_u_16 { impl insert_one_u_16 for super::RemoteReducers { fn insert_one_u_16(&self, n: u16) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_u16", InsertOneU16 { n }) + self.imp.call_reducer("insert_one_u16", InsertOneU16Args { n }) } fn on_insert_one_u_16( &self, mut callback: impl FnMut(&super::EventContext, &u16) + Send + 'static, ) -> InsertOneU16CallbackId { - InsertOneU16CallbackId(self.imp.on_reducer::( + InsertOneU16CallbackId(self.imp.on_reducer( "insert_one_u16", - Box::new(move |ctx: &super::EventContext, args: &InsertOneU16| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneU16 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_one_u_16(&self, callback: InsertOneU16CallbackId) { - self.imp.remove_on_reducer::("insert_one_u16", callback.0) + self.imp.remove_on_reducer("insert_one_u16", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_256_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_256_reducer.rs index 98c8c244247..7064582d845 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_256_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_256_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneU256 { +pub(super) struct InsertOneU256Args { pub n: __sats::u256, } -impl __sdk::spacetime_module::InModule for InsertOneU256 { +impl From for super::Reducer { + fn from(args: InsertOneU256Args) -> Self { + Self::InsertOneU256 { n: args.n } + } +} + +impl __sdk::InModule for InsertOneU256Args { type Module = super::RemoteModule; } -pub struct InsertOneU256CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneU256CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_u256`. @@ -52,20 +57,32 @@ pub trait insert_one_u_256 { impl insert_one_u_256 for super::RemoteReducers { fn insert_one_u_256(&self, n: __sats::u256) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_u256", InsertOneU256 { n }) + self.imp.call_reducer("insert_one_u256", InsertOneU256Args { n }) } fn on_insert_one_u_256( &self, mut callback: impl FnMut(&super::EventContext, &__sats::u256) + Send + 'static, ) -> InsertOneU256CallbackId { - InsertOneU256CallbackId(self.imp.on_reducer::( + InsertOneU256CallbackId(self.imp.on_reducer( "insert_one_u256", - Box::new(move |ctx: &super::EventContext, args: &InsertOneU256| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneU256 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_one_u_256(&self, callback: InsertOneU256CallbackId) { - self.imp - .remove_on_reducer::("insert_one_u256", callback.0) + self.imp.remove_on_reducer("insert_one_u256", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_32_reducer.rs index 3196c11caa4..56ffadc531b 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_32_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneU32 { +pub(super) struct InsertOneU32Args { pub n: u32, } -impl __sdk::spacetime_module::InModule for InsertOneU32 { +impl From for super::Reducer { + fn from(args: InsertOneU32Args) -> Self { + Self::InsertOneU32 { n: args.n } + } +} + +impl __sdk::InModule for InsertOneU32Args { type Module = super::RemoteModule; } -pub struct InsertOneU32CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneU32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_u32`. @@ -52,19 +57,32 @@ pub trait insert_one_u_32 { impl insert_one_u_32 for super::RemoteReducers { fn insert_one_u_32(&self, n: u32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_u32", InsertOneU32 { n }) + self.imp.call_reducer("insert_one_u32", InsertOneU32Args { n }) } fn on_insert_one_u_32( &self, mut callback: impl FnMut(&super::EventContext, &u32) + Send + 'static, ) -> InsertOneU32CallbackId { - InsertOneU32CallbackId(self.imp.on_reducer::( + InsertOneU32CallbackId(self.imp.on_reducer( "insert_one_u32", - Box::new(move |ctx: &super::EventContext, args: &InsertOneU32| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneU32 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_one_u_32(&self, callback: InsertOneU32CallbackId) { - self.imp.remove_on_reducer::("insert_one_u32", callback.0) + self.imp.remove_on_reducer("insert_one_u32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_64_reducer.rs index 1d213658af7..029c64eaee1 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_64_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneU64 { +pub(super) struct InsertOneU64Args { pub n: u64, } -impl __sdk::spacetime_module::InModule for InsertOneU64 { +impl From for super::Reducer { + fn from(args: InsertOneU64Args) -> Self { + Self::InsertOneU64 { n: args.n } + } +} + +impl __sdk::InModule for InsertOneU64Args { type Module = super::RemoteModule; } -pub struct InsertOneU64CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneU64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_u64`. @@ -52,19 +57,32 @@ pub trait insert_one_u_64 { impl insert_one_u_64 for super::RemoteReducers { fn insert_one_u_64(&self, n: u64) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_u64", InsertOneU64 { n }) + self.imp.call_reducer("insert_one_u64", InsertOneU64Args { n }) } fn on_insert_one_u_64( &self, mut callback: impl FnMut(&super::EventContext, &u64) + Send + 'static, ) -> InsertOneU64CallbackId { - InsertOneU64CallbackId(self.imp.on_reducer::( + InsertOneU64CallbackId(self.imp.on_reducer( "insert_one_u64", - Box::new(move |ctx: &super::EventContext, args: &InsertOneU64| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneU64 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_one_u_64(&self, callback: InsertOneU64CallbackId) { - self.imp.remove_on_reducer::("insert_one_u64", callback.0) + self.imp.remove_on_reducer("insert_one_u64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_8_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_8_reducer.rs index 3d3d14f7e9f..f11c7df20f6 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_8_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_u_8_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneU8 { +pub(super) struct InsertOneU8Args { pub n: u8, } -impl __sdk::spacetime_module::InModule for InsertOneU8 { +impl From for super::Reducer { + fn from(args: InsertOneU8Args) -> Self { + Self::InsertOneU8 { n: args.n } + } +} + +impl __sdk::InModule for InsertOneU8Args { type Module = super::RemoteModule; } -pub struct InsertOneU8CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneU8CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_u8`. @@ -52,19 +57,32 @@ pub trait insert_one_u_8 { impl insert_one_u_8 for super::RemoteReducers { fn insert_one_u_8(&self, n: u8) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_one_u8", InsertOneU8 { n }) + self.imp.call_reducer("insert_one_u8", InsertOneU8Args { n }) } fn on_insert_one_u_8( &self, mut callback: impl FnMut(&super::EventContext, &u8) + Send + 'static, ) -> InsertOneU8CallbackId { - InsertOneU8CallbackId(self.imp.on_reducer::( + InsertOneU8CallbackId(self.imp.on_reducer( "insert_one_u8", - Box::new(move |ctx: &super::EventContext, args: &InsertOneU8| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneU8 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_one_u_8(&self, callback: InsertOneU8CallbackId) { - self.imp.remove_on_reducer::("insert_one_u8", callback.0) + self.imp.remove_on_reducer("insert_one_u8", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_one_unit_struct_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_one_unit_struct_reducer.rs index d806945cfe6..3dd290d8ba2 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_one_unit_struct_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_one_unit_struct_reducer.rs @@ -2,25 +2,30 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::unit_struct_type::UnitStruct; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOneUnitStruct { +pub(super) struct InsertOneUnitStructArgs { pub s: UnitStruct, } -impl __sdk::spacetime_module::InModule for InsertOneUnitStruct { +impl From for super::Reducer { + fn from(args: InsertOneUnitStructArgs) -> Self { + Self::InsertOneUnitStruct { s: args.s } + } +} + +impl __sdk::InModule for InsertOneUnitStructArgs { type Module = super::RemoteModule; } -pub struct InsertOneUnitStructCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOneUnitStructCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_one_unit_struct`. @@ -55,20 +60,32 @@ pub trait insert_one_unit_struct { impl insert_one_unit_struct for super::RemoteReducers { fn insert_one_unit_struct(&self, s: UnitStruct) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_one_unit_struct", InsertOneUnitStruct { s }) + .call_reducer("insert_one_unit_struct", InsertOneUnitStructArgs { s }) } fn on_insert_one_unit_struct( &self, mut callback: impl FnMut(&super::EventContext, &UnitStruct) + Send + 'static, ) -> InsertOneUnitStructCallbackId { - InsertOneUnitStructCallbackId(self.imp.on_reducer::( + InsertOneUnitStructCallbackId(self.imp.on_reducer( "insert_one_unit_struct", - Box::new(move |ctx: &super::EventContext, args: &InsertOneUnitStruct| callback(ctx, &args.s)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOneUnitStruct { s }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s) + }), )) } fn remove_on_insert_one_unit_struct(&self, callback: InsertOneUnitStructCallbackId) { - self.imp - .remove_on_reducer::("insert_one_unit_struct", callback.0) + self.imp.remove_on_reducer("insert_one_unit_struct", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_option_every_primitive_struct_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_option_every_primitive_struct_reducer.rs index 2469942acab..bbb164eb06b 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_option_every_primitive_struct_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_option_every_primitive_struct_reducer.rs @@ -2,25 +2,30 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::every_primitive_struct_type::EveryPrimitiveStruct; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOptionEveryPrimitiveStruct { +pub(super) struct InsertOptionEveryPrimitiveStructArgs { pub s: Option, } -impl __sdk::spacetime_module::InModule for InsertOptionEveryPrimitiveStruct { +impl From for super::Reducer { + fn from(args: InsertOptionEveryPrimitiveStructArgs) -> Self { + Self::InsertOptionEveryPrimitiveStruct { s: args.s } + } +} + +impl __sdk::InModule for InsertOptionEveryPrimitiveStructArgs { type Module = super::RemoteModule; } -pub struct InsertOptionEveryPrimitiveStructCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOptionEveryPrimitiveStructCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_option_every_primitive_struct`. @@ -56,21 +61,34 @@ impl insert_option_every_primitive_struct for super::RemoteReducers { fn insert_option_every_primitive_struct(&self, s: Option) -> __anyhow::Result<()> { self.imp.call_reducer( "insert_option_every_primitive_struct", - InsertOptionEveryPrimitiveStruct { s }, + InsertOptionEveryPrimitiveStructArgs { s }, ) } fn on_insert_option_every_primitive_struct( &self, mut callback: impl FnMut(&super::EventContext, &Option) + Send + 'static, ) -> InsertOptionEveryPrimitiveStructCallbackId { - InsertOptionEveryPrimitiveStructCallbackId(self.imp.on_reducer::( + InsertOptionEveryPrimitiveStructCallbackId(self.imp.on_reducer( "insert_option_every_primitive_struct", - Box::new(move |ctx: &super::EventContext, args: &InsertOptionEveryPrimitiveStruct| callback(ctx, &args.s)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOptionEveryPrimitiveStruct { s }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s) + }), )) } fn remove_on_insert_option_every_primitive_struct(&self, callback: InsertOptionEveryPrimitiveStructCallbackId) { self.imp - .remove_on_reducer::("insert_option_every_primitive_struct", callback.0) + .remove_on_reducer("insert_option_every_primitive_struct", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_option_i_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_option_i_32_reducer.rs index 1645099c4bc..e0ecce5a2a2 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_option_i_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_option_i_32_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOptionI32 { +pub(super) struct InsertOptionI32Args { pub n: Option, } -impl __sdk::spacetime_module::InModule for InsertOptionI32 { +impl From for super::Reducer { + fn from(args: InsertOptionI32Args) -> Self { + Self::InsertOptionI32 { n: args.n } + } +} + +impl __sdk::InModule for InsertOptionI32Args { type Module = super::RemoteModule; } -pub struct InsertOptionI32CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOptionI32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_option_i32`. @@ -52,20 +57,32 @@ pub trait insert_option_i_32 { impl insert_option_i_32 for super::RemoteReducers { fn insert_option_i_32(&self, n: Option) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_option_i32", InsertOptionI32 { n }) + self.imp.call_reducer("insert_option_i32", InsertOptionI32Args { n }) } fn on_insert_option_i_32( &self, mut callback: impl FnMut(&super::EventContext, &Option) + Send + 'static, ) -> InsertOptionI32CallbackId { - InsertOptionI32CallbackId(self.imp.on_reducer::( + InsertOptionI32CallbackId(self.imp.on_reducer( "insert_option_i32", - Box::new(move |ctx: &super::EventContext, args: &InsertOptionI32| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOptionI32 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_option_i_32(&self, callback: InsertOptionI32CallbackId) { - self.imp - .remove_on_reducer::("insert_option_i32", callback.0) + self.imp.remove_on_reducer("insert_option_i32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_option_identity_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_option_identity_reducer.rs index b6a8094ac7b..0b6c4e4a8b8 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_option_identity_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_option_identity_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOptionIdentity { +pub(super) struct InsertOptionIdentityArgs { pub i: Option<__sdk::Identity>, } -impl __sdk::spacetime_module::InModule for InsertOptionIdentity { +impl From for super::Reducer { + fn from(args: InsertOptionIdentityArgs) -> Self { + Self::InsertOptionIdentity { i: args.i } + } +} + +impl __sdk::InModule for InsertOptionIdentityArgs { type Module = super::RemoteModule; } -pub struct InsertOptionIdentityCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOptionIdentityCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_option_identity`. @@ -53,20 +58,32 @@ pub trait insert_option_identity { impl insert_option_identity for super::RemoteReducers { fn insert_option_identity(&self, i: Option<__sdk::Identity>) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_option_identity", InsertOptionIdentity { i }) + .call_reducer("insert_option_identity", InsertOptionIdentityArgs { i }) } fn on_insert_option_identity( &self, mut callback: impl FnMut(&super::EventContext, &Option<__sdk::Identity>) + Send + 'static, ) -> InsertOptionIdentityCallbackId { - InsertOptionIdentityCallbackId(self.imp.on_reducer::( + InsertOptionIdentityCallbackId(self.imp.on_reducer( "insert_option_identity", - Box::new(move |ctx: &super::EventContext, args: &InsertOptionIdentity| callback(ctx, &args.i)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOptionIdentity { i }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, i) + }), )) } fn remove_on_insert_option_identity(&self, callback: InsertOptionIdentityCallbackId) { - self.imp - .remove_on_reducer::("insert_option_identity", callback.0) + self.imp.remove_on_reducer("insert_option_identity", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_option_simple_enum_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_option_simple_enum_reducer.rs index bd3bddfc289..37e17334e8b 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_option_simple_enum_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_option_simple_enum_reducer.rs @@ -2,25 +2,30 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::simple_enum_type::SimpleEnum; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOptionSimpleEnum { +pub(super) struct InsertOptionSimpleEnumArgs { pub e: Option, } -impl __sdk::spacetime_module::InModule for InsertOptionSimpleEnum { +impl From for super::Reducer { + fn from(args: InsertOptionSimpleEnumArgs) -> Self { + Self::InsertOptionSimpleEnum { e: args.e } + } +} + +impl __sdk::InModule for InsertOptionSimpleEnumArgs { type Module = super::RemoteModule; } -pub struct InsertOptionSimpleEnumCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOptionSimpleEnumCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_option_simple_enum`. @@ -55,20 +60,32 @@ pub trait insert_option_simple_enum { impl insert_option_simple_enum for super::RemoteReducers { fn insert_option_simple_enum(&self, e: Option) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_option_simple_enum", InsertOptionSimpleEnum { e }) + .call_reducer("insert_option_simple_enum", InsertOptionSimpleEnumArgs { e }) } fn on_insert_option_simple_enum( &self, mut callback: impl FnMut(&super::EventContext, &Option) + Send + 'static, ) -> InsertOptionSimpleEnumCallbackId { - InsertOptionSimpleEnumCallbackId(self.imp.on_reducer::( + InsertOptionSimpleEnumCallbackId(self.imp.on_reducer( "insert_option_simple_enum", - Box::new(move |ctx: &super::EventContext, args: &InsertOptionSimpleEnum| callback(ctx, &args.e)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOptionSimpleEnum { e }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, e) + }), )) } fn remove_on_insert_option_simple_enum(&self, callback: InsertOptionSimpleEnumCallbackId) { - self.imp - .remove_on_reducer::("insert_option_simple_enum", callback.0) + self.imp.remove_on_reducer("insert_option_simple_enum", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_option_string_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_option_string_reducer.rs index 62df5fc9637..fc238c09d83 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_option_string_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_option_string_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOptionString { +pub(super) struct InsertOptionStringArgs { pub s: Option, } -impl __sdk::spacetime_module::InModule for InsertOptionString { +impl From for super::Reducer { + fn from(args: InsertOptionStringArgs) -> Self { + Self::InsertOptionString { s: args.s } + } +} + +impl __sdk::InModule for InsertOptionStringArgs { type Module = super::RemoteModule; } -pub struct InsertOptionStringCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOptionStringCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_option_string`. @@ -52,20 +57,33 @@ pub trait insert_option_string { impl insert_option_string for super::RemoteReducers { fn insert_option_string(&self, s: Option) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_option_string", InsertOptionString { s }) + self.imp + .call_reducer("insert_option_string", InsertOptionStringArgs { s }) } fn on_insert_option_string( &self, mut callback: impl FnMut(&super::EventContext, &Option) + Send + 'static, ) -> InsertOptionStringCallbackId { - InsertOptionStringCallbackId(self.imp.on_reducer::( + InsertOptionStringCallbackId(self.imp.on_reducer( "insert_option_string", - Box::new(move |ctx: &super::EventContext, args: &InsertOptionString| callback(ctx, &args.s)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOptionString { s }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s) + }), )) } fn remove_on_insert_option_string(&self, callback: InsertOptionStringCallbackId) { - self.imp - .remove_on_reducer::("insert_option_string", callback.0) + self.imp.remove_on_reducer("insert_option_string", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_option_vec_option_i_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_option_vec_option_i_32_reducer.rs index a427a6036cc..3a970569949 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_option_vec_option_i_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_option_vec_option_i_32_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertOptionVecOptionI32 { +pub(super) struct InsertOptionVecOptionI32Args { pub v: Option>>, } -impl __sdk::spacetime_module::InModule for InsertOptionVecOptionI32 { +impl From for super::Reducer { + fn from(args: InsertOptionVecOptionI32Args) -> Self { + Self::InsertOptionVecOptionI32 { v: args.v } + } +} + +impl __sdk::InModule for InsertOptionVecOptionI32Args { type Module = super::RemoteModule; } -pub struct InsertOptionVecOptionI32CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertOptionVecOptionI32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_option_vec_option_i32`. @@ -53,20 +58,32 @@ pub trait insert_option_vec_option_i_32 { impl insert_option_vec_option_i_32 for super::RemoteReducers { fn insert_option_vec_option_i_32(&self, v: Option>>) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_option_vec_option_i32", InsertOptionVecOptionI32 { v }) + .call_reducer("insert_option_vec_option_i32", InsertOptionVecOptionI32Args { v }) } fn on_insert_option_vec_option_i_32( &self, mut callback: impl FnMut(&super::EventContext, &Option>>) + Send + 'static, ) -> InsertOptionVecOptionI32CallbackId { - InsertOptionVecOptionI32CallbackId(self.imp.on_reducer::( + InsertOptionVecOptionI32CallbackId(self.imp.on_reducer( "insert_option_vec_option_i32", - Box::new(move |ctx: &super::EventContext, args: &InsertOptionVecOptionI32| callback(ctx, &args.v)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertOptionVecOptionI32 { v }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, v) + }), )) } fn remove_on_insert_option_vec_option_i_32(&self, callback: InsertOptionVecOptionI32CallbackId) { - self.imp - .remove_on_reducer::("insert_option_vec_option_i32", callback.0) + self.imp.remove_on_reducer("insert_option_vec_option_i32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_address_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_address_reducer.rs index f5aba467538..61c0004fb23 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_address_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_address_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPkAddress { +pub(super) struct InsertPkAddressArgs { pub a: __sdk::Address, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertPkAddress { +impl From for super::Reducer { + fn from(args: InsertPkAddressArgs) -> Self { + Self::InsertPkAddress { + a: args.a, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertPkAddressArgs { type Module = super::RemoteModule; } -pub struct InsertPkAddressCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPkAddressCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_pk_address`. @@ -53,20 +61,33 @@ pub trait insert_pk_address { impl insert_pk_address for super::RemoteReducers { fn insert_pk_address(&self, a: __sdk::Address, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_pk_address", InsertPkAddress { a, data }) + self.imp + .call_reducer("insert_pk_address", InsertPkAddressArgs { a, data }) } fn on_insert_pk_address( &self, mut callback: impl FnMut(&super::EventContext, &__sdk::Address, &i32) + Send + 'static, ) -> InsertPkAddressCallbackId { - InsertPkAddressCallbackId(self.imp.on_reducer::( + InsertPkAddressCallbackId(self.imp.on_reducer( "insert_pk_address", - Box::new(move |ctx: &super::EventContext, args: &InsertPkAddress| callback(ctx, &args.a, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPkAddress { a, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, a, data) + }), )) } fn remove_on_insert_pk_address(&self, callback: InsertPkAddressCallbackId) { - self.imp - .remove_on_reducer::("insert_pk_address", callback.0) + self.imp.remove_on_reducer("insert_pk_address", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_bool_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_bool_reducer.rs index 57f45f08f6d..d835aae49df 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_bool_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_bool_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPkBool { +pub(super) struct InsertPkBoolArgs { pub b: bool, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertPkBool { +impl From for super::Reducer { + fn from(args: InsertPkBoolArgs) -> Self { + Self::InsertPkBool { + b: args.b, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertPkBoolArgs { type Module = super::RemoteModule; } -pub struct InsertPkBoolCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPkBoolCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_pk_bool`. @@ -53,19 +61,32 @@ pub trait insert_pk_bool { impl insert_pk_bool for super::RemoteReducers { fn insert_pk_bool(&self, b: bool, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_pk_bool", InsertPkBool { b, data }) + self.imp.call_reducer("insert_pk_bool", InsertPkBoolArgs { b, data }) } fn on_insert_pk_bool( &self, mut callback: impl FnMut(&super::EventContext, &bool, &i32) + Send + 'static, ) -> InsertPkBoolCallbackId { - InsertPkBoolCallbackId(self.imp.on_reducer::( + InsertPkBoolCallbackId(self.imp.on_reducer( "insert_pk_bool", - Box::new(move |ctx: &super::EventContext, args: &InsertPkBool| callback(ctx, &args.b, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPkBool { b, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, b, data) + }), )) } fn remove_on_insert_pk_bool(&self, callback: InsertPkBoolCallbackId) { - self.imp.remove_on_reducer::("insert_pk_bool", callback.0) + self.imp.remove_on_reducer("insert_pk_bool", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_128_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_128_reducer.rs index c759048ebf6..ef1b32e33b6 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_128_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_128_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPkI128 { +pub(super) struct InsertPkI128Args { pub n: i128, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertPkI128 { +impl From for super::Reducer { + fn from(args: InsertPkI128Args) -> Self { + Self::InsertPkI128 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertPkI128Args { type Module = super::RemoteModule; } -pub struct InsertPkI128CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPkI128CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_pk_i128`. @@ -53,19 +61,32 @@ pub trait insert_pk_i_128 { impl insert_pk_i_128 for super::RemoteReducers { fn insert_pk_i_128(&self, n: i128, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_pk_i128", InsertPkI128 { n, data }) + self.imp.call_reducer("insert_pk_i128", InsertPkI128Args { n, data }) } fn on_insert_pk_i_128( &self, mut callback: impl FnMut(&super::EventContext, &i128, &i32) + Send + 'static, ) -> InsertPkI128CallbackId { - InsertPkI128CallbackId(self.imp.on_reducer::( + InsertPkI128CallbackId(self.imp.on_reducer( "insert_pk_i128", - Box::new(move |ctx: &super::EventContext, args: &InsertPkI128| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPkI128 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_pk_i_128(&self, callback: InsertPkI128CallbackId) { - self.imp.remove_on_reducer::("insert_pk_i128", callback.0) + self.imp.remove_on_reducer("insert_pk_i128", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_16_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_16_reducer.rs index eeb2555c2c9..0bcb1bcc625 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_16_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_16_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPkI16 { +pub(super) struct InsertPkI16Args { pub n: i16, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertPkI16 { +impl From for super::Reducer { + fn from(args: InsertPkI16Args) -> Self { + Self::InsertPkI16 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertPkI16Args { type Module = super::RemoteModule; } -pub struct InsertPkI16CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPkI16CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_pk_i16`. @@ -53,19 +61,32 @@ pub trait insert_pk_i_16 { impl insert_pk_i_16 for super::RemoteReducers { fn insert_pk_i_16(&self, n: i16, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_pk_i16", InsertPkI16 { n, data }) + self.imp.call_reducer("insert_pk_i16", InsertPkI16Args { n, data }) } fn on_insert_pk_i_16( &self, mut callback: impl FnMut(&super::EventContext, &i16, &i32) + Send + 'static, ) -> InsertPkI16CallbackId { - InsertPkI16CallbackId(self.imp.on_reducer::( + InsertPkI16CallbackId(self.imp.on_reducer( "insert_pk_i16", - Box::new(move |ctx: &super::EventContext, args: &InsertPkI16| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPkI16 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_pk_i_16(&self, callback: InsertPkI16CallbackId) { - self.imp.remove_on_reducer::("insert_pk_i16", callback.0) + self.imp.remove_on_reducer("insert_pk_i16", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_256_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_256_reducer.rs index abc52651fac..f4faae41b83 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_256_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_256_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPkI256 { +pub(super) struct InsertPkI256Args { pub n: __sats::i256, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertPkI256 { +impl From for super::Reducer { + fn from(args: InsertPkI256Args) -> Self { + Self::InsertPkI256 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertPkI256Args { type Module = super::RemoteModule; } -pub struct InsertPkI256CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPkI256CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_pk_i256`. @@ -53,19 +61,32 @@ pub trait insert_pk_i_256 { impl insert_pk_i_256 for super::RemoteReducers { fn insert_pk_i_256(&self, n: __sats::i256, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_pk_i256", InsertPkI256 { n, data }) + self.imp.call_reducer("insert_pk_i256", InsertPkI256Args { n, data }) } fn on_insert_pk_i_256( &self, mut callback: impl FnMut(&super::EventContext, &__sats::i256, &i32) + Send + 'static, ) -> InsertPkI256CallbackId { - InsertPkI256CallbackId(self.imp.on_reducer::( + InsertPkI256CallbackId(self.imp.on_reducer( "insert_pk_i256", - Box::new(move |ctx: &super::EventContext, args: &InsertPkI256| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPkI256 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_pk_i_256(&self, callback: InsertPkI256CallbackId) { - self.imp.remove_on_reducer::("insert_pk_i256", callback.0) + self.imp.remove_on_reducer("insert_pk_i256", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_32_reducer.rs index d2ab5dc024d..1a73e884d34 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_32_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPkI32 { +pub(super) struct InsertPkI32Args { pub n: i32, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertPkI32 { +impl From for super::Reducer { + fn from(args: InsertPkI32Args) -> Self { + Self::InsertPkI32 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertPkI32Args { type Module = super::RemoteModule; } -pub struct InsertPkI32CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPkI32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_pk_i32`. @@ -53,19 +61,32 @@ pub trait insert_pk_i_32 { impl insert_pk_i_32 for super::RemoteReducers { fn insert_pk_i_32(&self, n: i32, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_pk_i32", InsertPkI32 { n, data }) + self.imp.call_reducer("insert_pk_i32", InsertPkI32Args { n, data }) } fn on_insert_pk_i_32( &self, mut callback: impl FnMut(&super::EventContext, &i32, &i32) + Send + 'static, ) -> InsertPkI32CallbackId { - InsertPkI32CallbackId(self.imp.on_reducer::( + InsertPkI32CallbackId(self.imp.on_reducer( "insert_pk_i32", - Box::new(move |ctx: &super::EventContext, args: &InsertPkI32| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPkI32 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_pk_i_32(&self, callback: InsertPkI32CallbackId) { - self.imp.remove_on_reducer::("insert_pk_i32", callback.0) + self.imp.remove_on_reducer("insert_pk_i32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_64_reducer.rs index 3858e6fd81f..aaddb742e38 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_64_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPkI64 { +pub(super) struct InsertPkI64Args { pub n: i64, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertPkI64 { +impl From for super::Reducer { + fn from(args: InsertPkI64Args) -> Self { + Self::InsertPkI64 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertPkI64Args { type Module = super::RemoteModule; } -pub struct InsertPkI64CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPkI64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_pk_i64`. @@ -53,19 +61,32 @@ pub trait insert_pk_i_64 { impl insert_pk_i_64 for super::RemoteReducers { fn insert_pk_i_64(&self, n: i64, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_pk_i64", InsertPkI64 { n, data }) + self.imp.call_reducer("insert_pk_i64", InsertPkI64Args { n, data }) } fn on_insert_pk_i_64( &self, mut callback: impl FnMut(&super::EventContext, &i64, &i32) + Send + 'static, ) -> InsertPkI64CallbackId { - InsertPkI64CallbackId(self.imp.on_reducer::( + InsertPkI64CallbackId(self.imp.on_reducer( "insert_pk_i64", - Box::new(move |ctx: &super::EventContext, args: &InsertPkI64| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPkI64 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_pk_i_64(&self, callback: InsertPkI64CallbackId) { - self.imp.remove_on_reducer::("insert_pk_i64", callback.0) + self.imp.remove_on_reducer("insert_pk_i64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_8_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_8_reducer.rs index 492a45487c7..6dfd2f38b45 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_8_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_i_8_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPkI8 { +pub(super) struct InsertPkI8Args { pub n: i8, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertPkI8 { +impl From for super::Reducer { + fn from(args: InsertPkI8Args) -> Self { + Self::InsertPkI8 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertPkI8Args { type Module = super::RemoteModule; } -pub struct InsertPkI8CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPkI8CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_pk_i8`. @@ -53,19 +61,32 @@ pub trait insert_pk_i_8 { impl insert_pk_i_8 for super::RemoteReducers { fn insert_pk_i_8(&self, n: i8, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_pk_i8", InsertPkI8 { n, data }) + self.imp.call_reducer("insert_pk_i8", InsertPkI8Args { n, data }) } fn on_insert_pk_i_8( &self, mut callback: impl FnMut(&super::EventContext, &i8, &i32) + Send + 'static, ) -> InsertPkI8CallbackId { - InsertPkI8CallbackId(self.imp.on_reducer::( + InsertPkI8CallbackId(self.imp.on_reducer( "insert_pk_i8", - Box::new(move |ctx: &super::EventContext, args: &InsertPkI8| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPkI8 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_pk_i_8(&self, callback: InsertPkI8CallbackId) { - self.imp.remove_on_reducer::("insert_pk_i8", callback.0) + self.imp.remove_on_reducer("insert_pk_i8", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_identity_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_identity_reducer.rs index 045b52060b4..c5a76694058 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_identity_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_identity_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPkIdentity { +pub(super) struct InsertPkIdentityArgs { pub i: __sdk::Identity, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertPkIdentity { +impl From for super::Reducer { + fn from(args: InsertPkIdentityArgs) -> Self { + Self::InsertPkIdentity { + i: args.i, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertPkIdentityArgs { type Module = super::RemoteModule; } -pub struct InsertPkIdentityCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPkIdentityCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_pk_identity`. @@ -54,20 +62,32 @@ pub trait insert_pk_identity { impl insert_pk_identity for super::RemoteReducers { fn insert_pk_identity(&self, i: __sdk::Identity, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_pk_identity", InsertPkIdentity { i, data }) + .call_reducer("insert_pk_identity", InsertPkIdentityArgs { i, data }) } fn on_insert_pk_identity( &self, mut callback: impl FnMut(&super::EventContext, &__sdk::Identity, &i32) + Send + 'static, ) -> InsertPkIdentityCallbackId { - InsertPkIdentityCallbackId(self.imp.on_reducer::( + InsertPkIdentityCallbackId(self.imp.on_reducer( "insert_pk_identity", - Box::new(move |ctx: &super::EventContext, args: &InsertPkIdentity| callback(ctx, &args.i, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPkIdentity { i, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, i, data) + }), )) } fn remove_on_insert_pk_identity(&self, callback: InsertPkIdentityCallbackId) { - self.imp - .remove_on_reducer::("insert_pk_identity", callback.0) + self.imp.remove_on_reducer("insert_pk_identity", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_string_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_string_reducer.rs index 930917a9f42..73b3063753b 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_string_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_string_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPkString { +pub(super) struct InsertPkStringArgs { pub s: String, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertPkString { +impl From for super::Reducer { + fn from(args: InsertPkStringArgs) -> Self { + Self::InsertPkString { + s: args.s, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertPkStringArgs { type Module = super::RemoteModule; } -pub struct InsertPkStringCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPkStringCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_pk_string`. @@ -53,20 +61,33 @@ pub trait insert_pk_string { impl insert_pk_string for super::RemoteReducers { fn insert_pk_string(&self, s: String, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_pk_string", InsertPkString { s, data }) + self.imp + .call_reducer("insert_pk_string", InsertPkStringArgs { s, data }) } fn on_insert_pk_string( &self, mut callback: impl FnMut(&super::EventContext, &String, &i32) + Send + 'static, ) -> InsertPkStringCallbackId { - InsertPkStringCallbackId(self.imp.on_reducer::( + InsertPkStringCallbackId(self.imp.on_reducer( "insert_pk_string", - Box::new(move |ctx: &super::EventContext, args: &InsertPkString| callback(ctx, &args.s, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPkString { s, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s, data) + }), )) } fn remove_on_insert_pk_string(&self, callback: InsertPkStringCallbackId) { - self.imp - .remove_on_reducer::("insert_pk_string", callback.0) + self.imp.remove_on_reducer("insert_pk_string", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_128_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_128_reducer.rs index f66528a632c..3dd088dd66a 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_128_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_128_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPkU128 { +pub(super) struct InsertPkU128Args { pub n: u128, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertPkU128 { +impl From for super::Reducer { + fn from(args: InsertPkU128Args) -> Self { + Self::InsertPkU128 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertPkU128Args { type Module = super::RemoteModule; } -pub struct InsertPkU128CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPkU128CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_pk_u128`. @@ -53,19 +61,32 @@ pub trait insert_pk_u_128 { impl insert_pk_u_128 for super::RemoteReducers { fn insert_pk_u_128(&self, n: u128, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_pk_u128", InsertPkU128 { n, data }) + self.imp.call_reducer("insert_pk_u128", InsertPkU128Args { n, data }) } fn on_insert_pk_u_128( &self, mut callback: impl FnMut(&super::EventContext, &u128, &i32) + Send + 'static, ) -> InsertPkU128CallbackId { - InsertPkU128CallbackId(self.imp.on_reducer::( + InsertPkU128CallbackId(self.imp.on_reducer( "insert_pk_u128", - Box::new(move |ctx: &super::EventContext, args: &InsertPkU128| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPkU128 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_pk_u_128(&self, callback: InsertPkU128CallbackId) { - self.imp.remove_on_reducer::("insert_pk_u128", callback.0) + self.imp.remove_on_reducer("insert_pk_u128", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_16_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_16_reducer.rs index 523a26e4e69..8d53fd031fb 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_16_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_16_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPkU16 { +pub(super) struct InsertPkU16Args { pub n: u16, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertPkU16 { +impl From for super::Reducer { + fn from(args: InsertPkU16Args) -> Self { + Self::InsertPkU16 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertPkU16Args { type Module = super::RemoteModule; } -pub struct InsertPkU16CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPkU16CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_pk_u16`. @@ -53,19 +61,32 @@ pub trait insert_pk_u_16 { impl insert_pk_u_16 for super::RemoteReducers { fn insert_pk_u_16(&self, n: u16, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_pk_u16", InsertPkU16 { n, data }) + self.imp.call_reducer("insert_pk_u16", InsertPkU16Args { n, data }) } fn on_insert_pk_u_16( &self, mut callback: impl FnMut(&super::EventContext, &u16, &i32) + Send + 'static, ) -> InsertPkU16CallbackId { - InsertPkU16CallbackId(self.imp.on_reducer::( + InsertPkU16CallbackId(self.imp.on_reducer( "insert_pk_u16", - Box::new(move |ctx: &super::EventContext, args: &InsertPkU16| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPkU16 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_pk_u_16(&self, callback: InsertPkU16CallbackId) { - self.imp.remove_on_reducer::("insert_pk_u16", callback.0) + self.imp.remove_on_reducer("insert_pk_u16", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_256_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_256_reducer.rs index 8be24c42cf8..d6907302cf6 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_256_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_256_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPkU256 { +pub(super) struct InsertPkU256Args { pub n: __sats::u256, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertPkU256 { +impl From for super::Reducer { + fn from(args: InsertPkU256Args) -> Self { + Self::InsertPkU256 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertPkU256Args { type Module = super::RemoteModule; } -pub struct InsertPkU256CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPkU256CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_pk_u256`. @@ -53,19 +61,32 @@ pub trait insert_pk_u_256 { impl insert_pk_u_256 for super::RemoteReducers { fn insert_pk_u_256(&self, n: __sats::u256, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_pk_u256", InsertPkU256 { n, data }) + self.imp.call_reducer("insert_pk_u256", InsertPkU256Args { n, data }) } fn on_insert_pk_u_256( &self, mut callback: impl FnMut(&super::EventContext, &__sats::u256, &i32) + Send + 'static, ) -> InsertPkU256CallbackId { - InsertPkU256CallbackId(self.imp.on_reducer::( + InsertPkU256CallbackId(self.imp.on_reducer( "insert_pk_u256", - Box::new(move |ctx: &super::EventContext, args: &InsertPkU256| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPkU256 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_pk_u_256(&self, callback: InsertPkU256CallbackId) { - self.imp.remove_on_reducer::("insert_pk_u256", callback.0) + self.imp.remove_on_reducer("insert_pk_u256", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_32_reducer.rs index d64e320bded..24b1a7456b2 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_32_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPkU32 { +pub(super) struct InsertPkU32Args { pub n: u32, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertPkU32 { +impl From for super::Reducer { + fn from(args: InsertPkU32Args) -> Self { + Self::InsertPkU32 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertPkU32Args { type Module = super::RemoteModule; } -pub struct InsertPkU32CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPkU32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_pk_u32`. @@ -53,19 +61,32 @@ pub trait insert_pk_u_32 { impl insert_pk_u_32 for super::RemoteReducers { fn insert_pk_u_32(&self, n: u32, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_pk_u32", InsertPkU32 { n, data }) + self.imp.call_reducer("insert_pk_u32", InsertPkU32Args { n, data }) } fn on_insert_pk_u_32( &self, mut callback: impl FnMut(&super::EventContext, &u32, &i32) + Send + 'static, ) -> InsertPkU32CallbackId { - InsertPkU32CallbackId(self.imp.on_reducer::( + InsertPkU32CallbackId(self.imp.on_reducer( "insert_pk_u32", - Box::new(move |ctx: &super::EventContext, args: &InsertPkU32| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPkU32 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_pk_u_32(&self, callback: InsertPkU32CallbackId) { - self.imp.remove_on_reducer::("insert_pk_u32", callback.0) + self.imp.remove_on_reducer("insert_pk_u32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_64_reducer.rs index 1d58f1a5a24..cb82f2e4ee5 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_64_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPkU64 { +pub(super) struct InsertPkU64Args { pub n: u64, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertPkU64 { +impl From for super::Reducer { + fn from(args: InsertPkU64Args) -> Self { + Self::InsertPkU64 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertPkU64Args { type Module = super::RemoteModule; } -pub struct InsertPkU64CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPkU64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_pk_u64`. @@ -53,19 +61,32 @@ pub trait insert_pk_u_64 { impl insert_pk_u_64 for super::RemoteReducers { fn insert_pk_u_64(&self, n: u64, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_pk_u64", InsertPkU64 { n, data }) + self.imp.call_reducer("insert_pk_u64", InsertPkU64Args { n, data }) } fn on_insert_pk_u_64( &self, mut callback: impl FnMut(&super::EventContext, &u64, &i32) + Send + 'static, ) -> InsertPkU64CallbackId { - InsertPkU64CallbackId(self.imp.on_reducer::( + InsertPkU64CallbackId(self.imp.on_reducer( "insert_pk_u64", - Box::new(move |ctx: &super::EventContext, args: &InsertPkU64| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPkU64 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_pk_u_64(&self, callback: InsertPkU64CallbackId) { - self.imp.remove_on_reducer::("insert_pk_u64", callback.0) + self.imp.remove_on_reducer("insert_pk_u64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_8_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_8_reducer.rs index 26a320bac70..fdad9f9e7e5 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_8_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_pk_u_8_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPkU8 { +pub(super) struct InsertPkU8Args { pub n: u8, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertPkU8 { +impl From for super::Reducer { + fn from(args: InsertPkU8Args) -> Self { + Self::InsertPkU8 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertPkU8Args { type Module = super::RemoteModule; } -pub struct InsertPkU8CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPkU8CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_pk_u8`. @@ -53,19 +61,32 @@ pub trait insert_pk_u_8 { impl insert_pk_u_8 for super::RemoteReducers { fn insert_pk_u_8(&self, n: u8, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_pk_u8", InsertPkU8 { n, data }) + self.imp.call_reducer("insert_pk_u8", InsertPkU8Args { n, data }) } fn on_insert_pk_u_8( &self, mut callback: impl FnMut(&super::EventContext, &u8, &i32) + Send + 'static, ) -> InsertPkU8CallbackId { - InsertPkU8CallbackId(self.imp.on_reducer::( + InsertPkU8CallbackId(self.imp.on_reducer( "insert_pk_u8", - Box::new(move |ctx: &super::EventContext, args: &InsertPkU8| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPkU8 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_pk_u_8(&self, callback: InsertPkU8CallbackId) { - self.imp.remove_on_reducer::("insert_pk_u8", callback.0) + self.imp.remove_on_reducer("insert_pk_u8", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_primitives_as_strings_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_primitives_as_strings_reducer.rs index 3538a93a302..416fb4908fd 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_primitives_as_strings_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_primitives_as_strings_reducer.rs @@ -2,25 +2,30 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::every_primitive_struct_type::EveryPrimitiveStruct; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertPrimitivesAsStrings { +pub(super) struct InsertPrimitivesAsStringsArgs { pub s: EveryPrimitiveStruct, } -impl __sdk::spacetime_module::InModule for InsertPrimitivesAsStrings { +impl From for super::Reducer { + fn from(args: InsertPrimitivesAsStringsArgs) -> Self { + Self::InsertPrimitivesAsStrings { s: args.s } + } +} + +impl __sdk::InModule for InsertPrimitivesAsStringsArgs { type Module = super::RemoteModule; } -pub struct InsertPrimitivesAsStringsCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertPrimitivesAsStringsCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_primitives_as_strings`. @@ -55,20 +60,32 @@ pub trait insert_primitives_as_strings { impl insert_primitives_as_strings for super::RemoteReducers { fn insert_primitives_as_strings(&self, s: EveryPrimitiveStruct) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_primitives_as_strings", InsertPrimitivesAsStrings { s }) + .call_reducer("insert_primitives_as_strings", InsertPrimitivesAsStringsArgs { s }) } fn on_insert_primitives_as_strings( &self, mut callback: impl FnMut(&super::EventContext, &EveryPrimitiveStruct) + Send + 'static, ) -> InsertPrimitivesAsStringsCallbackId { - InsertPrimitivesAsStringsCallbackId(self.imp.on_reducer::( + InsertPrimitivesAsStringsCallbackId(self.imp.on_reducer( "insert_primitives_as_strings", - Box::new(move |ctx: &super::EventContext, args: &InsertPrimitivesAsStrings| callback(ctx, &args.s)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertPrimitivesAsStrings { s }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s) + }), )) } fn remove_on_insert_primitives_as_strings(&self, callback: InsertPrimitivesAsStringsCallbackId) { - self.imp - .remove_on_reducer::("insert_primitives_as_strings", callback.0) + self.imp.remove_on_reducer("insert_primitives_as_strings", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_table_holds_table_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_table_holds_table_reducer.rs index 57e61923ae2..2ba2fce3613 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_table_holds_table_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_table_holds_table_reducer.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::one_u_8_type::OneU8; @@ -13,16 +12,22 @@ use super::vec_u_8_type::VecU8; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertTableHoldsTable { +pub(super) struct InsertTableHoldsTableArgs { pub a: OneU8, pub b: VecU8, } -impl __sdk::spacetime_module::InModule for InsertTableHoldsTable { +impl From for super::Reducer { + fn from(args: InsertTableHoldsTableArgs) -> Self { + Self::InsertTableHoldsTable { a: args.a, b: args.b } + } +} + +impl __sdk::InModule for InsertTableHoldsTableArgs { type Module = super::RemoteModule; } -pub struct InsertTableHoldsTableCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertTableHoldsTableCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_table_holds_table`. @@ -57,20 +62,32 @@ pub trait insert_table_holds_table { impl insert_table_holds_table for super::RemoteReducers { fn insert_table_holds_table(&self, a: OneU8, b: VecU8) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_table_holds_table", InsertTableHoldsTable { a, b }) + .call_reducer("insert_table_holds_table", InsertTableHoldsTableArgs { a, b }) } fn on_insert_table_holds_table( &self, mut callback: impl FnMut(&super::EventContext, &OneU8, &VecU8) + Send + 'static, ) -> InsertTableHoldsTableCallbackId { - InsertTableHoldsTableCallbackId(self.imp.on_reducer::( + InsertTableHoldsTableCallbackId(self.imp.on_reducer( "insert_table_holds_table", - Box::new(move |ctx: &super::EventContext, args: &InsertTableHoldsTable| callback(ctx, &args.a, &args.b)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertTableHoldsTable { a, b }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, a, b) + }), )) } fn remove_on_insert_table_holds_table(&self, callback: InsertTableHoldsTableCallbackId) { - self.imp - .remove_on_reducer::("insert_table_holds_table", callback.0) + self.imp.remove_on_reducer("insert_table_holds_table", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_address_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_address_reducer.rs index aae98d1d331..4d0d2372066 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_address_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_address_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertUniqueAddress { +pub(super) struct InsertUniqueAddressArgs { pub a: __sdk::Address, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertUniqueAddress { +impl From for super::Reducer { + fn from(args: InsertUniqueAddressArgs) -> Self { + Self::InsertUniqueAddress { + a: args.a, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertUniqueAddressArgs { type Module = super::RemoteModule; } -pub struct InsertUniqueAddressCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertUniqueAddressCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_unique_address`. @@ -54,20 +62,32 @@ pub trait insert_unique_address { impl insert_unique_address for super::RemoteReducers { fn insert_unique_address(&self, a: __sdk::Address, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_unique_address", InsertUniqueAddress { a, data }) + .call_reducer("insert_unique_address", InsertUniqueAddressArgs { a, data }) } fn on_insert_unique_address( &self, mut callback: impl FnMut(&super::EventContext, &__sdk::Address, &i32) + Send + 'static, ) -> InsertUniqueAddressCallbackId { - InsertUniqueAddressCallbackId(self.imp.on_reducer::( + InsertUniqueAddressCallbackId(self.imp.on_reducer( "insert_unique_address", - Box::new(move |ctx: &super::EventContext, args: &InsertUniqueAddress| callback(ctx, &args.a, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertUniqueAddress { a, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, a, data) + }), )) } fn remove_on_insert_unique_address(&self, callback: InsertUniqueAddressCallbackId) { - self.imp - .remove_on_reducer::("insert_unique_address", callback.0) + self.imp.remove_on_reducer("insert_unique_address", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_bool_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_bool_reducer.rs index b035dfd07b8..5b69e95a1c6 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_bool_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_bool_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertUniqueBool { +pub(super) struct InsertUniqueBoolArgs { pub b: bool, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertUniqueBool { +impl From for super::Reducer { + fn from(args: InsertUniqueBoolArgs) -> Self { + Self::InsertUniqueBool { + b: args.b, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertUniqueBoolArgs { type Module = super::RemoteModule; } -pub struct InsertUniqueBoolCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertUniqueBoolCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_unique_bool`. @@ -54,20 +62,32 @@ pub trait insert_unique_bool { impl insert_unique_bool for super::RemoteReducers { fn insert_unique_bool(&self, b: bool, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_unique_bool", InsertUniqueBool { b, data }) + .call_reducer("insert_unique_bool", InsertUniqueBoolArgs { b, data }) } fn on_insert_unique_bool( &self, mut callback: impl FnMut(&super::EventContext, &bool, &i32) + Send + 'static, ) -> InsertUniqueBoolCallbackId { - InsertUniqueBoolCallbackId(self.imp.on_reducer::( + InsertUniqueBoolCallbackId(self.imp.on_reducer( "insert_unique_bool", - Box::new(move |ctx: &super::EventContext, args: &InsertUniqueBool| callback(ctx, &args.b, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertUniqueBool { b, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, b, data) + }), )) } fn remove_on_insert_unique_bool(&self, callback: InsertUniqueBoolCallbackId) { - self.imp - .remove_on_reducer::("insert_unique_bool", callback.0) + self.imp.remove_on_reducer("insert_unique_bool", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_128_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_128_reducer.rs index e44e77f5a8c..fc9d0426bb2 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_128_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_128_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertUniqueI128 { +pub(super) struct InsertUniqueI128Args { pub n: i128, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertUniqueI128 { +impl From for super::Reducer { + fn from(args: InsertUniqueI128Args) -> Self { + Self::InsertUniqueI128 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertUniqueI128Args { type Module = super::RemoteModule; } -pub struct InsertUniqueI128CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertUniqueI128CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_unique_i128`. @@ -54,20 +62,32 @@ pub trait insert_unique_i_128 { impl insert_unique_i_128 for super::RemoteReducers { fn insert_unique_i_128(&self, n: i128, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_unique_i128", InsertUniqueI128 { n, data }) + .call_reducer("insert_unique_i128", InsertUniqueI128Args { n, data }) } fn on_insert_unique_i_128( &self, mut callback: impl FnMut(&super::EventContext, &i128, &i32) + Send + 'static, ) -> InsertUniqueI128CallbackId { - InsertUniqueI128CallbackId(self.imp.on_reducer::( + InsertUniqueI128CallbackId(self.imp.on_reducer( "insert_unique_i128", - Box::new(move |ctx: &super::EventContext, args: &InsertUniqueI128| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertUniqueI128 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_unique_i_128(&self, callback: InsertUniqueI128CallbackId) { - self.imp - .remove_on_reducer::("insert_unique_i128", callback.0) + self.imp.remove_on_reducer("insert_unique_i128", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_16_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_16_reducer.rs index 5bc6b4aba3a..562b5df700a 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_16_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_16_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertUniqueI16 { +pub(super) struct InsertUniqueI16Args { pub n: i16, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertUniqueI16 { +impl From for super::Reducer { + fn from(args: InsertUniqueI16Args) -> Self { + Self::InsertUniqueI16 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertUniqueI16Args { type Module = super::RemoteModule; } -pub struct InsertUniqueI16CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertUniqueI16CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_unique_i16`. @@ -53,20 +61,33 @@ pub trait insert_unique_i_16 { impl insert_unique_i_16 for super::RemoteReducers { fn insert_unique_i_16(&self, n: i16, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_unique_i16", InsertUniqueI16 { n, data }) + self.imp + .call_reducer("insert_unique_i16", InsertUniqueI16Args { n, data }) } fn on_insert_unique_i_16( &self, mut callback: impl FnMut(&super::EventContext, &i16, &i32) + Send + 'static, ) -> InsertUniqueI16CallbackId { - InsertUniqueI16CallbackId(self.imp.on_reducer::( + InsertUniqueI16CallbackId(self.imp.on_reducer( "insert_unique_i16", - Box::new(move |ctx: &super::EventContext, args: &InsertUniqueI16| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertUniqueI16 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_unique_i_16(&self, callback: InsertUniqueI16CallbackId) { - self.imp - .remove_on_reducer::("insert_unique_i16", callback.0) + self.imp.remove_on_reducer("insert_unique_i16", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_256_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_256_reducer.rs index bbbcce0c566..27ef2559a88 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_256_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_256_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertUniqueI256 { +pub(super) struct InsertUniqueI256Args { pub n: __sats::i256, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertUniqueI256 { +impl From for super::Reducer { + fn from(args: InsertUniqueI256Args) -> Self { + Self::InsertUniqueI256 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertUniqueI256Args { type Module = super::RemoteModule; } -pub struct InsertUniqueI256CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertUniqueI256CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_unique_i256`. @@ -54,20 +62,32 @@ pub trait insert_unique_i_256 { impl insert_unique_i_256 for super::RemoteReducers { fn insert_unique_i_256(&self, n: __sats::i256, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_unique_i256", InsertUniqueI256 { n, data }) + .call_reducer("insert_unique_i256", InsertUniqueI256Args { n, data }) } fn on_insert_unique_i_256( &self, mut callback: impl FnMut(&super::EventContext, &__sats::i256, &i32) + Send + 'static, ) -> InsertUniqueI256CallbackId { - InsertUniqueI256CallbackId(self.imp.on_reducer::( + InsertUniqueI256CallbackId(self.imp.on_reducer( "insert_unique_i256", - Box::new(move |ctx: &super::EventContext, args: &InsertUniqueI256| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertUniqueI256 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_unique_i_256(&self, callback: InsertUniqueI256CallbackId) { - self.imp - .remove_on_reducer::("insert_unique_i256", callback.0) + self.imp.remove_on_reducer("insert_unique_i256", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_32_reducer.rs index 9a797693ee8..331b5d62ea8 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_32_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertUniqueI32 { +pub(super) struct InsertUniqueI32Args { pub n: i32, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertUniqueI32 { +impl From for super::Reducer { + fn from(args: InsertUniqueI32Args) -> Self { + Self::InsertUniqueI32 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertUniqueI32Args { type Module = super::RemoteModule; } -pub struct InsertUniqueI32CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertUniqueI32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_unique_i32`. @@ -53,20 +61,33 @@ pub trait insert_unique_i_32 { impl insert_unique_i_32 for super::RemoteReducers { fn insert_unique_i_32(&self, n: i32, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_unique_i32", InsertUniqueI32 { n, data }) + self.imp + .call_reducer("insert_unique_i32", InsertUniqueI32Args { n, data }) } fn on_insert_unique_i_32( &self, mut callback: impl FnMut(&super::EventContext, &i32, &i32) + Send + 'static, ) -> InsertUniqueI32CallbackId { - InsertUniqueI32CallbackId(self.imp.on_reducer::( + InsertUniqueI32CallbackId(self.imp.on_reducer( "insert_unique_i32", - Box::new(move |ctx: &super::EventContext, args: &InsertUniqueI32| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertUniqueI32 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_unique_i_32(&self, callback: InsertUniqueI32CallbackId) { - self.imp - .remove_on_reducer::("insert_unique_i32", callback.0) + self.imp.remove_on_reducer("insert_unique_i32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_64_reducer.rs index 3ec098e667e..bf5d4ae2f0b 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_64_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertUniqueI64 { +pub(super) struct InsertUniqueI64Args { pub n: i64, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertUniqueI64 { +impl From for super::Reducer { + fn from(args: InsertUniqueI64Args) -> Self { + Self::InsertUniqueI64 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertUniqueI64Args { type Module = super::RemoteModule; } -pub struct InsertUniqueI64CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertUniqueI64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_unique_i64`. @@ -53,20 +61,33 @@ pub trait insert_unique_i_64 { impl insert_unique_i_64 for super::RemoteReducers { fn insert_unique_i_64(&self, n: i64, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_unique_i64", InsertUniqueI64 { n, data }) + self.imp + .call_reducer("insert_unique_i64", InsertUniqueI64Args { n, data }) } fn on_insert_unique_i_64( &self, mut callback: impl FnMut(&super::EventContext, &i64, &i32) + Send + 'static, ) -> InsertUniqueI64CallbackId { - InsertUniqueI64CallbackId(self.imp.on_reducer::( + InsertUniqueI64CallbackId(self.imp.on_reducer( "insert_unique_i64", - Box::new(move |ctx: &super::EventContext, args: &InsertUniqueI64| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertUniqueI64 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_unique_i_64(&self, callback: InsertUniqueI64CallbackId) { - self.imp - .remove_on_reducer::("insert_unique_i64", callback.0) + self.imp.remove_on_reducer("insert_unique_i64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_8_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_8_reducer.rs index fca339652bf..6ffb9227946 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_8_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_i_8_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertUniqueI8 { +pub(super) struct InsertUniqueI8Args { pub n: i8, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertUniqueI8 { +impl From for super::Reducer { + fn from(args: InsertUniqueI8Args) -> Self { + Self::InsertUniqueI8 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertUniqueI8Args { type Module = super::RemoteModule; } -pub struct InsertUniqueI8CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertUniqueI8CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_unique_i8`. @@ -53,20 +61,33 @@ pub trait insert_unique_i_8 { impl insert_unique_i_8 for super::RemoteReducers { fn insert_unique_i_8(&self, n: i8, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_unique_i8", InsertUniqueI8 { n, data }) + self.imp + .call_reducer("insert_unique_i8", InsertUniqueI8Args { n, data }) } fn on_insert_unique_i_8( &self, mut callback: impl FnMut(&super::EventContext, &i8, &i32) + Send + 'static, ) -> InsertUniqueI8CallbackId { - InsertUniqueI8CallbackId(self.imp.on_reducer::( + InsertUniqueI8CallbackId(self.imp.on_reducer( "insert_unique_i8", - Box::new(move |ctx: &super::EventContext, args: &InsertUniqueI8| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertUniqueI8 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_unique_i_8(&self, callback: InsertUniqueI8CallbackId) { - self.imp - .remove_on_reducer::("insert_unique_i8", callback.0) + self.imp.remove_on_reducer("insert_unique_i8", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_identity_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_identity_reducer.rs index cdea4a89483..858d4814ea7 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_identity_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_identity_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertUniqueIdentity { +pub(super) struct InsertUniqueIdentityArgs { pub i: __sdk::Identity, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertUniqueIdentity { +impl From for super::Reducer { + fn from(args: InsertUniqueIdentityArgs) -> Self { + Self::InsertUniqueIdentity { + i: args.i, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertUniqueIdentityArgs { type Module = super::RemoteModule; } -pub struct InsertUniqueIdentityCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertUniqueIdentityCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_unique_identity`. @@ -54,20 +62,32 @@ pub trait insert_unique_identity { impl insert_unique_identity for super::RemoteReducers { fn insert_unique_identity(&self, i: __sdk::Identity, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_unique_identity", InsertUniqueIdentity { i, data }) + .call_reducer("insert_unique_identity", InsertUniqueIdentityArgs { i, data }) } fn on_insert_unique_identity( &self, mut callback: impl FnMut(&super::EventContext, &__sdk::Identity, &i32) + Send + 'static, ) -> InsertUniqueIdentityCallbackId { - InsertUniqueIdentityCallbackId(self.imp.on_reducer::( + InsertUniqueIdentityCallbackId(self.imp.on_reducer( "insert_unique_identity", - Box::new(move |ctx: &super::EventContext, args: &InsertUniqueIdentity| callback(ctx, &args.i, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertUniqueIdentity { i, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, i, data) + }), )) } fn remove_on_insert_unique_identity(&self, callback: InsertUniqueIdentityCallbackId) { - self.imp - .remove_on_reducer::("insert_unique_identity", callback.0) + self.imp.remove_on_reducer("insert_unique_identity", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_string_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_string_reducer.rs index 732ffcd8a09..ec033a12478 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_string_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_string_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertUniqueString { +pub(super) struct InsertUniqueStringArgs { pub s: String, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertUniqueString { +impl From for super::Reducer { + fn from(args: InsertUniqueStringArgs) -> Self { + Self::InsertUniqueString { + s: args.s, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertUniqueStringArgs { type Module = super::RemoteModule; } -pub struct InsertUniqueStringCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertUniqueStringCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_unique_string`. @@ -54,20 +62,32 @@ pub trait insert_unique_string { impl insert_unique_string for super::RemoteReducers { fn insert_unique_string(&self, s: String, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_unique_string", InsertUniqueString { s, data }) + .call_reducer("insert_unique_string", InsertUniqueStringArgs { s, data }) } fn on_insert_unique_string( &self, mut callback: impl FnMut(&super::EventContext, &String, &i32) + Send + 'static, ) -> InsertUniqueStringCallbackId { - InsertUniqueStringCallbackId(self.imp.on_reducer::( + InsertUniqueStringCallbackId(self.imp.on_reducer( "insert_unique_string", - Box::new(move |ctx: &super::EventContext, args: &InsertUniqueString| callback(ctx, &args.s, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertUniqueString { s, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s, data) + }), )) } fn remove_on_insert_unique_string(&self, callback: InsertUniqueStringCallbackId) { - self.imp - .remove_on_reducer::("insert_unique_string", callback.0) + self.imp.remove_on_reducer("insert_unique_string", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_128_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_128_reducer.rs index 980b7f3a0c2..c05908488dd 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_128_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_128_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertUniqueU128 { +pub(super) struct InsertUniqueU128Args { pub n: u128, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertUniqueU128 { +impl From for super::Reducer { + fn from(args: InsertUniqueU128Args) -> Self { + Self::InsertUniqueU128 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertUniqueU128Args { type Module = super::RemoteModule; } -pub struct InsertUniqueU128CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertUniqueU128CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_unique_u128`. @@ -54,20 +62,32 @@ pub trait insert_unique_u_128 { impl insert_unique_u_128 for super::RemoteReducers { fn insert_unique_u_128(&self, n: u128, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_unique_u128", InsertUniqueU128 { n, data }) + .call_reducer("insert_unique_u128", InsertUniqueU128Args { n, data }) } fn on_insert_unique_u_128( &self, mut callback: impl FnMut(&super::EventContext, &u128, &i32) + Send + 'static, ) -> InsertUniqueU128CallbackId { - InsertUniqueU128CallbackId(self.imp.on_reducer::( + InsertUniqueU128CallbackId(self.imp.on_reducer( "insert_unique_u128", - Box::new(move |ctx: &super::EventContext, args: &InsertUniqueU128| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertUniqueU128 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_unique_u_128(&self, callback: InsertUniqueU128CallbackId) { - self.imp - .remove_on_reducer::("insert_unique_u128", callback.0) + self.imp.remove_on_reducer("insert_unique_u128", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_16_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_16_reducer.rs index 7faf69e02a4..3bdeac4e448 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_16_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_16_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertUniqueU16 { +pub(super) struct InsertUniqueU16Args { pub n: u16, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertUniqueU16 { +impl From for super::Reducer { + fn from(args: InsertUniqueU16Args) -> Self { + Self::InsertUniqueU16 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertUniqueU16Args { type Module = super::RemoteModule; } -pub struct InsertUniqueU16CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertUniqueU16CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_unique_u16`. @@ -53,20 +61,33 @@ pub trait insert_unique_u_16 { impl insert_unique_u_16 for super::RemoteReducers { fn insert_unique_u_16(&self, n: u16, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_unique_u16", InsertUniqueU16 { n, data }) + self.imp + .call_reducer("insert_unique_u16", InsertUniqueU16Args { n, data }) } fn on_insert_unique_u_16( &self, mut callback: impl FnMut(&super::EventContext, &u16, &i32) + Send + 'static, ) -> InsertUniqueU16CallbackId { - InsertUniqueU16CallbackId(self.imp.on_reducer::( + InsertUniqueU16CallbackId(self.imp.on_reducer( "insert_unique_u16", - Box::new(move |ctx: &super::EventContext, args: &InsertUniqueU16| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertUniqueU16 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_unique_u_16(&self, callback: InsertUniqueU16CallbackId) { - self.imp - .remove_on_reducer::("insert_unique_u16", callback.0) + self.imp.remove_on_reducer("insert_unique_u16", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_256_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_256_reducer.rs index 9360698d6fc..b4a7116da3e 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_256_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_256_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertUniqueU256 { +pub(super) struct InsertUniqueU256Args { pub n: __sats::u256, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertUniqueU256 { +impl From for super::Reducer { + fn from(args: InsertUniqueU256Args) -> Self { + Self::InsertUniqueU256 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertUniqueU256Args { type Module = super::RemoteModule; } -pub struct InsertUniqueU256CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertUniqueU256CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_unique_u256`. @@ -54,20 +62,32 @@ pub trait insert_unique_u_256 { impl insert_unique_u_256 for super::RemoteReducers { fn insert_unique_u_256(&self, n: __sats::u256, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_unique_u256", InsertUniqueU256 { n, data }) + .call_reducer("insert_unique_u256", InsertUniqueU256Args { n, data }) } fn on_insert_unique_u_256( &self, mut callback: impl FnMut(&super::EventContext, &__sats::u256, &i32) + Send + 'static, ) -> InsertUniqueU256CallbackId { - InsertUniqueU256CallbackId(self.imp.on_reducer::( + InsertUniqueU256CallbackId(self.imp.on_reducer( "insert_unique_u256", - Box::new(move |ctx: &super::EventContext, args: &InsertUniqueU256| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertUniqueU256 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_unique_u_256(&self, callback: InsertUniqueU256CallbackId) { - self.imp - .remove_on_reducer::("insert_unique_u256", callback.0) + self.imp.remove_on_reducer("insert_unique_u256", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_32_reducer.rs index 6f12f882dee..449d7c73388 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_32_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertUniqueU32 { +pub(super) struct InsertUniqueU32Args { pub n: u32, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertUniqueU32 { +impl From for super::Reducer { + fn from(args: InsertUniqueU32Args) -> Self { + Self::InsertUniqueU32 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertUniqueU32Args { type Module = super::RemoteModule; } -pub struct InsertUniqueU32CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertUniqueU32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_unique_u32`. @@ -53,20 +61,33 @@ pub trait insert_unique_u_32 { impl insert_unique_u_32 for super::RemoteReducers { fn insert_unique_u_32(&self, n: u32, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_unique_u32", InsertUniqueU32 { n, data }) + self.imp + .call_reducer("insert_unique_u32", InsertUniqueU32Args { n, data }) } fn on_insert_unique_u_32( &self, mut callback: impl FnMut(&super::EventContext, &u32, &i32) + Send + 'static, ) -> InsertUniqueU32CallbackId { - InsertUniqueU32CallbackId(self.imp.on_reducer::( + InsertUniqueU32CallbackId(self.imp.on_reducer( "insert_unique_u32", - Box::new(move |ctx: &super::EventContext, args: &InsertUniqueU32| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertUniqueU32 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_unique_u_32(&self, callback: InsertUniqueU32CallbackId) { - self.imp - .remove_on_reducer::("insert_unique_u32", callback.0) + self.imp.remove_on_reducer("insert_unique_u32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_64_reducer.rs index aedd948c1f5..a58c598f9ed 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_64_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertUniqueU64 { +pub(super) struct InsertUniqueU64Args { pub n: u64, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertUniqueU64 { +impl From for super::Reducer { + fn from(args: InsertUniqueU64Args) -> Self { + Self::InsertUniqueU64 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertUniqueU64Args { type Module = super::RemoteModule; } -pub struct InsertUniqueU64CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertUniqueU64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_unique_u64`. @@ -53,20 +61,33 @@ pub trait insert_unique_u_64 { impl insert_unique_u_64 for super::RemoteReducers { fn insert_unique_u_64(&self, n: u64, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_unique_u64", InsertUniqueU64 { n, data }) + self.imp + .call_reducer("insert_unique_u64", InsertUniqueU64Args { n, data }) } fn on_insert_unique_u_64( &self, mut callback: impl FnMut(&super::EventContext, &u64, &i32) + Send + 'static, ) -> InsertUniqueU64CallbackId { - InsertUniqueU64CallbackId(self.imp.on_reducer::( + InsertUniqueU64CallbackId(self.imp.on_reducer( "insert_unique_u64", - Box::new(move |ctx: &super::EventContext, args: &InsertUniqueU64| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertUniqueU64 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_unique_u_64(&self, callback: InsertUniqueU64CallbackId) { - self.imp - .remove_on_reducer::("insert_unique_u64", callback.0) + self.imp.remove_on_reducer("insert_unique_u64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_8_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_8_reducer.rs index c7179a933a0..ca2334ce778 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_8_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_unique_u_8_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertUniqueU8 { +pub(super) struct InsertUniqueU8Args { pub n: u8, pub data: i32, } -impl __sdk::spacetime_module::InModule for InsertUniqueU8 { +impl From for super::Reducer { + fn from(args: InsertUniqueU8Args) -> Self { + Self::InsertUniqueU8 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for InsertUniqueU8Args { type Module = super::RemoteModule; } -pub struct InsertUniqueU8CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertUniqueU8CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_unique_u8`. @@ -53,20 +61,33 @@ pub trait insert_unique_u_8 { impl insert_unique_u_8 for super::RemoteReducers { fn insert_unique_u_8(&self, n: u8, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_unique_u8", InsertUniqueU8 { n, data }) + self.imp + .call_reducer("insert_unique_u8", InsertUniqueU8Args { n, data }) } fn on_insert_unique_u_8( &self, mut callback: impl FnMut(&super::EventContext, &u8, &i32) + Send + 'static, ) -> InsertUniqueU8CallbackId { - InsertUniqueU8CallbackId(self.imp.on_reducer::( + InsertUniqueU8CallbackId(self.imp.on_reducer( "insert_unique_u8", - Box::new(move |ctx: &super::EventContext, args: &InsertUniqueU8| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertUniqueU8 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_insert_unique_u_8(&self, callback: InsertUniqueU8CallbackId) { - self.imp - .remove_on_reducer::("insert_unique_u8", callback.0) + self.imp.remove_on_reducer("insert_unique_u8", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_address_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_address_reducer.rs index 65ba4d7cb4e..781b71b490e 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_address_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_address_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecAddress { +pub(super) struct InsertVecAddressArgs { pub a: Vec<__sdk::Address>, } -impl __sdk::spacetime_module::InModule for InsertVecAddress { +impl From for super::Reducer { + fn from(args: InsertVecAddressArgs) -> Self { + Self::InsertVecAddress { a: args.a } + } +} + +impl __sdk::InModule for InsertVecAddressArgs { type Module = super::RemoteModule; } -pub struct InsertVecAddressCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecAddressCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_address`. @@ -52,20 +57,32 @@ pub trait insert_vec_address { impl insert_vec_address for super::RemoteReducers { fn insert_vec_address(&self, a: Vec<__sdk::Address>) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_address", InsertVecAddress { a }) + self.imp.call_reducer("insert_vec_address", InsertVecAddressArgs { a }) } fn on_insert_vec_address( &self, mut callback: impl FnMut(&super::EventContext, &Vec<__sdk::Address>) + Send + 'static, ) -> InsertVecAddressCallbackId { - InsertVecAddressCallbackId(self.imp.on_reducer::( + InsertVecAddressCallbackId(self.imp.on_reducer( "insert_vec_address", - Box::new(move |ctx: &super::EventContext, args: &InsertVecAddress| callback(ctx, &args.a)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecAddress { a }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, a) + }), )) } fn remove_on_insert_vec_address(&self, callback: InsertVecAddressCallbackId) { - self.imp - .remove_on_reducer::("insert_vec_address", callback.0) + self.imp.remove_on_reducer("insert_vec_address", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_bool_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_bool_reducer.rs index 375fb8054c0..8818df9cba9 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_bool_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_bool_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecBool { +pub(super) struct InsertVecBoolArgs { pub b: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecBool { +impl From for super::Reducer { + fn from(args: InsertVecBoolArgs) -> Self { + Self::InsertVecBool { b: args.b } + } +} + +impl __sdk::InModule for InsertVecBoolArgs { type Module = super::RemoteModule; } -pub struct InsertVecBoolCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecBoolCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_bool`. @@ -52,20 +57,32 @@ pub trait insert_vec_bool { impl insert_vec_bool for super::RemoteReducers { fn insert_vec_bool(&self, b: Vec) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_bool", InsertVecBool { b }) + self.imp.call_reducer("insert_vec_bool", InsertVecBoolArgs { b }) } fn on_insert_vec_bool( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecBoolCallbackId { - InsertVecBoolCallbackId(self.imp.on_reducer::( + InsertVecBoolCallbackId(self.imp.on_reducer( "insert_vec_bool", - Box::new(move |ctx: &super::EventContext, args: &InsertVecBool| callback(ctx, &args.b)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecBool { b }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, b) + }), )) } fn remove_on_insert_vec_bool(&self, callback: InsertVecBoolCallbackId) { - self.imp - .remove_on_reducer::("insert_vec_bool", callback.0) + self.imp.remove_on_reducer("insert_vec_bool", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_byte_struct_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_byte_struct_reducer.rs index 05d89ba4491..56607412096 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_byte_struct_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_byte_struct_reducer.rs @@ -2,25 +2,30 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::byte_struct_type::ByteStruct; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecByteStruct { +pub(super) struct InsertVecByteStructArgs { pub s: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecByteStruct { +impl From for super::Reducer { + fn from(args: InsertVecByteStructArgs) -> Self { + Self::InsertVecByteStruct { s: args.s } + } +} + +impl __sdk::InModule for InsertVecByteStructArgs { type Module = super::RemoteModule; } -pub struct InsertVecByteStructCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecByteStructCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_byte_struct`. @@ -55,20 +60,32 @@ pub trait insert_vec_byte_struct { impl insert_vec_byte_struct for super::RemoteReducers { fn insert_vec_byte_struct(&self, s: Vec) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_vec_byte_struct", InsertVecByteStruct { s }) + .call_reducer("insert_vec_byte_struct", InsertVecByteStructArgs { s }) } fn on_insert_vec_byte_struct( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecByteStructCallbackId { - InsertVecByteStructCallbackId(self.imp.on_reducer::( + InsertVecByteStructCallbackId(self.imp.on_reducer( "insert_vec_byte_struct", - Box::new(move |ctx: &super::EventContext, args: &InsertVecByteStruct| callback(ctx, &args.s)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecByteStruct { s }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s) + }), )) } fn remove_on_insert_vec_byte_struct(&self, callback: InsertVecByteStructCallbackId) { - self.imp - .remove_on_reducer::("insert_vec_byte_struct", callback.0) + self.imp.remove_on_reducer("insert_vec_byte_struct", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_enum_with_payload_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_enum_with_payload_reducer.rs index 30f786e2388..ce7e92293a0 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_enum_with_payload_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_enum_with_payload_reducer.rs @@ -2,25 +2,30 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::enum_with_payload_type::EnumWithPayload; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecEnumWithPayload { +pub(super) struct InsertVecEnumWithPayloadArgs { pub e: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecEnumWithPayload { +impl From for super::Reducer { + fn from(args: InsertVecEnumWithPayloadArgs) -> Self { + Self::InsertVecEnumWithPayload { e: args.e } + } +} + +impl __sdk::InModule for InsertVecEnumWithPayloadArgs { type Module = super::RemoteModule; } -pub struct InsertVecEnumWithPayloadCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecEnumWithPayloadCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_enum_with_payload`. @@ -55,20 +60,32 @@ pub trait insert_vec_enum_with_payload { impl insert_vec_enum_with_payload for super::RemoteReducers { fn insert_vec_enum_with_payload(&self, e: Vec) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_vec_enum_with_payload", InsertVecEnumWithPayload { e }) + .call_reducer("insert_vec_enum_with_payload", InsertVecEnumWithPayloadArgs { e }) } fn on_insert_vec_enum_with_payload( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecEnumWithPayloadCallbackId { - InsertVecEnumWithPayloadCallbackId(self.imp.on_reducer::( + InsertVecEnumWithPayloadCallbackId(self.imp.on_reducer( "insert_vec_enum_with_payload", - Box::new(move |ctx: &super::EventContext, args: &InsertVecEnumWithPayload| callback(ctx, &args.e)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecEnumWithPayload { e }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, e) + }), )) } fn remove_on_insert_vec_enum_with_payload(&self, callback: InsertVecEnumWithPayloadCallbackId) { - self.imp - .remove_on_reducer::("insert_vec_enum_with_payload", callback.0) + self.imp.remove_on_reducer("insert_vec_enum_with_payload", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_every_primitive_struct_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_every_primitive_struct_reducer.rs index 93bc294f3fa..873e2b4973f 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_every_primitive_struct_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_every_primitive_struct_reducer.rs @@ -2,25 +2,30 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::every_primitive_struct_type::EveryPrimitiveStruct; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecEveryPrimitiveStruct { +pub(super) struct InsertVecEveryPrimitiveStructArgs { pub s: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecEveryPrimitiveStruct { +impl From for super::Reducer { + fn from(args: InsertVecEveryPrimitiveStructArgs) -> Self { + Self::InsertVecEveryPrimitiveStruct { s: args.s } + } +} + +impl __sdk::InModule for InsertVecEveryPrimitiveStructArgs { type Module = super::RemoteModule; } -pub struct InsertVecEveryPrimitiveStructCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecEveryPrimitiveStructCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_every_primitive_struct`. @@ -54,21 +59,36 @@ pub trait insert_vec_every_primitive_struct { impl insert_vec_every_primitive_struct for super::RemoteReducers { fn insert_vec_every_primitive_struct(&self, s: Vec) -> __anyhow::Result<()> { - self.imp - .call_reducer("insert_vec_every_primitive_struct", InsertVecEveryPrimitiveStruct { s }) + self.imp.call_reducer( + "insert_vec_every_primitive_struct", + InsertVecEveryPrimitiveStructArgs { s }, + ) } fn on_insert_vec_every_primitive_struct( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecEveryPrimitiveStructCallbackId { - InsertVecEveryPrimitiveStructCallbackId(self.imp.on_reducer::( + InsertVecEveryPrimitiveStructCallbackId(self.imp.on_reducer( "insert_vec_every_primitive_struct", - Box::new(move |ctx: &super::EventContext, args: &InsertVecEveryPrimitiveStruct| callback(ctx, &args.s)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecEveryPrimitiveStruct { s }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s) + }), )) } fn remove_on_insert_vec_every_primitive_struct(&self, callback: InsertVecEveryPrimitiveStructCallbackId) { self.imp - .remove_on_reducer::("insert_vec_every_primitive_struct", callback.0) + .remove_on_reducer("insert_vec_every_primitive_struct", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_every_vec_struct_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_every_vec_struct_reducer.rs index a230c84c5aa..db8906df8ad 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_every_vec_struct_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_every_vec_struct_reducer.rs @@ -2,25 +2,30 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::every_vec_struct_type::EveryVecStruct; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecEveryVecStruct { +pub(super) struct InsertVecEveryVecStructArgs { pub s: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecEveryVecStruct { +impl From for super::Reducer { + fn from(args: InsertVecEveryVecStructArgs) -> Self { + Self::InsertVecEveryVecStruct { s: args.s } + } +} + +impl __sdk::InModule for InsertVecEveryVecStructArgs { type Module = super::RemoteModule; } -pub struct InsertVecEveryVecStructCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecEveryVecStructCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_every_vec_struct`. @@ -55,20 +60,32 @@ pub trait insert_vec_every_vec_struct { impl insert_vec_every_vec_struct for super::RemoteReducers { fn insert_vec_every_vec_struct(&self, s: Vec) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_vec_every_vec_struct", InsertVecEveryVecStruct { s }) + .call_reducer("insert_vec_every_vec_struct", InsertVecEveryVecStructArgs { s }) } fn on_insert_vec_every_vec_struct( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecEveryVecStructCallbackId { - InsertVecEveryVecStructCallbackId(self.imp.on_reducer::( + InsertVecEveryVecStructCallbackId(self.imp.on_reducer( "insert_vec_every_vec_struct", - Box::new(move |ctx: &super::EventContext, args: &InsertVecEveryVecStruct| callback(ctx, &args.s)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecEveryVecStruct { s }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s) + }), )) } fn remove_on_insert_vec_every_vec_struct(&self, callback: InsertVecEveryVecStructCallbackId) { - self.imp - .remove_on_reducer::("insert_vec_every_vec_struct", callback.0) + self.imp.remove_on_reducer("insert_vec_every_vec_struct", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_f_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_f_32_reducer.rs index c9d8fd540f8..c8ed6a79340 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_f_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_f_32_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecF32 { +pub(super) struct InsertVecF32Args { pub f: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecF32 { +impl From for super::Reducer { + fn from(args: InsertVecF32Args) -> Self { + Self::InsertVecF32 { f: args.f } + } +} + +impl __sdk::InModule for InsertVecF32Args { type Module = super::RemoteModule; } -pub struct InsertVecF32CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecF32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_f32`. @@ -52,19 +57,32 @@ pub trait insert_vec_f_32 { impl insert_vec_f_32 for super::RemoteReducers { fn insert_vec_f_32(&self, f: Vec) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_f32", InsertVecF32 { f }) + self.imp.call_reducer("insert_vec_f32", InsertVecF32Args { f }) } fn on_insert_vec_f_32( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecF32CallbackId { - InsertVecF32CallbackId(self.imp.on_reducer::( + InsertVecF32CallbackId(self.imp.on_reducer( "insert_vec_f32", - Box::new(move |ctx: &super::EventContext, args: &InsertVecF32| callback(ctx, &args.f)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecF32 { f }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, f) + }), )) } fn remove_on_insert_vec_f_32(&self, callback: InsertVecF32CallbackId) { - self.imp.remove_on_reducer::("insert_vec_f32", callback.0) + self.imp.remove_on_reducer("insert_vec_f32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_f_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_f_64_reducer.rs index 2407b5266a8..4c5af75c89c 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_f_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_f_64_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecF64 { +pub(super) struct InsertVecF64Args { pub f: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecF64 { +impl From for super::Reducer { + fn from(args: InsertVecF64Args) -> Self { + Self::InsertVecF64 { f: args.f } + } +} + +impl __sdk::InModule for InsertVecF64Args { type Module = super::RemoteModule; } -pub struct InsertVecF64CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecF64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_f64`. @@ -52,19 +57,32 @@ pub trait insert_vec_f_64 { impl insert_vec_f_64 for super::RemoteReducers { fn insert_vec_f_64(&self, f: Vec) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_f64", InsertVecF64 { f }) + self.imp.call_reducer("insert_vec_f64", InsertVecF64Args { f }) } fn on_insert_vec_f_64( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecF64CallbackId { - InsertVecF64CallbackId(self.imp.on_reducer::( + InsertVecF64CallbackId(self.imp.on_reducer( "insert_vec_f64", - Box::new(move |ctx: &super::EventContext, args: &InsertVecF64| callback(ctx, &args.f)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecF64 { f }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, f) + }), )) } fn remove_on_insert_vec_f_64(&self, callback: InsertVecF64CallbackId) { - self.imp.remove_on_reducer::("insert_vec_f64", callback.0) + self.imp.remove_on_reducer("insert_vec_f64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_128_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_128_reducer.rs index 90908728b9c..a04d1a52e3a 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_128_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_128_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecI128 { +pub(super) struct InsertVecI128Args { pub n: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecI128 { +impl From for super::Reducer { + fn from(args: InsertVecI128Args) -> Self { + Self::InsertVecI128 { n: args.n } + } +} + +impl __sdk::InModule for InsertVecI128Args { type Module = super::RemoteModule; } -pub struct InsertVecI128CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecI128CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_i128`. @@ -52,20 +57,32 @@ pub trait insert_vec_i_128 { impl insert_vec_i_128 for super::RemoteReducers { fn insert_vec_i_128(&self, n: Vec) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_i128", InsertVecI128 { n }) + self.imp.call_reducer("insert_vec_i128", InsertVecI128Args { n }) } fn on_insert_vec_i_128( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecI128CallbackId { - InsertVecI128CallbackId(self.imp.on_reducer::( + InsertVecI128CallbackId(self.imp.on_reducer( "insert_vec_i128", - Box::new(move |ctx: &super::EventContext, args: &InsertVecI128| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecI128 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_vec_i_128(&self, callback: InsertVecI128CallbackId) { - self.imp - .remove_on_reducer::("insert_vec_i128", callback.0) + self.imp.remove_on_reducer("insert_vec_i128", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_16_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_16_reducer.rs index 72a7ff9ec0a..8169aca35f0 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_16_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_16_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecI16 { +pub(super) struct InsertVecI16Args { pub n: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecI16 { +impl From for super::Reducer { + fn from(args: InsertVecI16Args) -> Self { + Self::InsertVecI16 { n: args.n } + } +} + +impl __sdk::InModule for InsertVecI16Args { type Module = super::RemoteModule; } -pub struct InsertVecI16CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecI16CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_i16`. @@ -52,19 +57,32 @@ pub trait insert_vec_i_16 { impl insert_vec_i_16 for super::RemoteReducers { fn insert_vec_i_16(&self, n: Vec) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_i16", InsertVecI16 { n }) + self.imp.call_reducer("insert_vec_i16", InsertVecI16Args { n }) } fn on_insert_vec_i_16( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecI16CallbackId { - InsertVecI16CallbackId(self.imp.on_reducer::( + InsertVecI16CallbackId(self.imp.on_reducer( "insert_vec_i16", - Box::new(move |ctx: &super::EventContext, args: &InsertVecI16| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecI16 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_vec_i_16(&self, callback: InsertVecI16CallbackId) { - self.imp.remove_on_reducer::("insert_vec_i16", callback.0) + self.imp.remove_on_reducer("insert_vec_i16", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_256_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_256_reducer.rs index 7596e4121aa..209993ee6d8 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_256_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_256_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecI256 { +pub(super) struct InsertVecI256Args { pub n: Vec<__sats::i256>, } -impl __sdk::spacetime_module::InModule for InsertVecI256 { +impl From for super::Reducer { + fn from(args: InsertVecI256Args) -> Self { + Self::InsertVecI256 { n: args.n } + } +} + +impl __sdk::InModule for InsertVecI256Args { type Module = super::RemoteModule; } -pub struct InsertVecI256CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecI256CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_i256`. @@ -52,20 +57,32 @@ pub trait insert_vec_i_256 { impl insert_vec_i_256 for super::RemoteReducers { fn insert_vec_i_256(&self, n: Vec<__sats::i256>) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_i256", InsertVecI256 { n }) + self.imp.call_reducer("insert_vec_i256", InsertVecI256Args { n }) } fn on_insert_vec_i_256( &self, mut callback: impl FnMut(&super::EventContext, &Vec<__sats::i256>) + Send + 'static, ) -> InsertVecI256CallbackId { - InsertVecI256CallbackId(self.imp.on_reducer::( + InsertVecI256CallbackId(self.imp.on_reducer( "insert_vec_i256", - Box::new(move |ctx: &super::EventContext, args: &InsertVecI256| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecI256 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_vec_i_256(&self, callback: InsertVecI256CallbackId) { - self.imp - .remove_on_reducer::("insert_vec_i256", callback.0) + self.imp.remove_on_reducer("insert_vec_i256", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_32_reducer.rs index 625cb995737..24493518739 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_32_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecI32 { +pub(super) struct InsertVecI32Args { pub n: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecI32 { +impl From for super::Reducer { + fn from(args: InsertVecI32Args) -> Self { + Self::InsertVecI32 { n: args.n } + } +} + +impl __sdk::InModule for InsertVecI32Args { type Module = super::RemoteModule; } -pub struct InsertVecI32CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecI32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_i32`. @@ -52,19 +57,32 @@ pub trait insert_vec_i_32 { impl insert_vec_i_32 for super::RemoteReducers { fn insert_vec_i_32(&self, n: Vec) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_i32", InsertVecI32 { n }) + self.imp.call_reducer("insert_vec_i32", InsertVecI32Args { n }) } fn on_insert_vec_i_32( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecI32CallbackId { - InsertVecI32CallbackId(self.imp.on_reducer::( + InsertVecI32CallbackId(self.imp.on_reducer( "insert_vec_i32", - Box::new(move |ctx: &super::EventContext, args: &InsertVecI32| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecI32 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_vec_i_32(&self, callback: InsertVecI32CallbackId) { - self.imp.remove_on_reducer::("insert_vec_i32", callback.0) + self.imp.remove_on_reducer("insert_vec_i32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_64_reducer.rs index db04cdcd294..dfffc9bdb7a 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_64_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecI64 { +pub(super) struct InsertVecI64Args { pub n: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecI64 { +impl From for super::Reducer { + fn from(args: InsertVecI64Args) -> Self { + Self::InsertVecI64 { n: args.n } + } +} + +impl __sdk::InModule for InsertVecI64Args { type Module = super::RemoteModule; } -pub struct InsertVecI64CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecI64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_i64`. @@ -52,19 +57,32 @@ pub trait insert_vec_i_64 { impl insert_vec_i_64 for super::RemoteReducers { fn insert_vec_i_64(&self, n: Vec) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_i64", InsertVecI64 { n }) + self.imp.call_reducer("insert_vec_i64", InsertVecI64Args { n }) } fn on_insert_vec_i_64( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecI64CallbackId { - InsertVecI64CallbackId(self.imp.on_reducer::( + InsertVecI64CallbackId(self.imp.on_reducer( "insert_vec_i64", - Box::new(move |ctx: &super::EventContext, args: &InsertVecI64| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecI64 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_vec_i_64(&self, callback: InsertVecI64CallbackId) { - self.imp.remove_on_reducer::("insert_vec_i64", callback.0) + self.imp.remove_on_reducer("insert_vec_i64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_8_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_8_reducer.rs index 2b1aaea964a..d3761b706cc 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_8_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_i_8_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecI8 { +pub(super) struct InsertVecI8Args { pub n: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecI8 { +impl From for super::Reducer { + fn from(args: InsertVecI8Args) -> Self { + Self::InsertVecI8 { n: args.n } + } +} + +impl __sdk::InModule for InsertVecI8Args { type Module = super::RemoteModule; } -pub struct InsertVecI8CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecI8CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_i8`. @@ -52,19 +57,32 @@ pub trait insert_vec_i_8 { impl insert_vec_i_8 for super::RemoteReducers { fn insert_vec_i_8(&self, n: Vec) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_i8", InsertVecI8 { n }) + self.imp.call_reducer("insert_vec_i8", InsertVecI8Args { n }) } fn on_insert_vec_i_8( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecI8CallbackId { - InsertVecI8CallbackId(self.imp.on_reducer::( + InsertVecI8CallbackId(self.imp.on_reducer( "insert_vec_i8", - Box::new(move |ctx: &super::EventContext, args: &InsertVecI8| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecI8 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_vec_i_8(&self, callback: InsertVecI8CallbackId) { - self.imp.remove_on_reducer::("insert_vec_i8", callback.0) + self.imp.remove_on_reducer("insert_vec_i8", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_identity_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_identity_reducer.rs index 3d598bb5c74..a0e92be987d 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_identity_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_identity_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecIdentity { +pub(super) struct InsertVecIdentityArgs { pub i: Vec<__sdk::Identity>, } -impl __sdk::spacetime_module::InModule for InsertVecIdentity { +impl From for super::Reducer { + fn from(args: InsertVecIdentityArgs) -> Self { + Self::InsertVecIdentity { i: args.i } + } +} + +impl __sdk::InModule for InsertVecIdentityArgs { type Module = super::RemoteModule; } -pub struct InsertVecIdentityCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecIdentityCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_identity`. @@ -52,20 +57,33 @@ pub trait insert_vec_identity { impl insert_vec_identity for super::RemoteReducers { fn insert_vec_identity(&self, i: Vec<__sdk::Identity>) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_identity", InsertVecIdentity { i }) + self.imp + .call_reducer("insert_vec_identity", InsertVecIdentityArgs { i }) } fn on_insert_vec_identity( &self, mut callback: impl FnMut(&super::EventContext, &Vec<__sdk::Identity>) + Send + 'static, ) -> InsertVecIdentityCallbackId { - InsertVecIdentityCallbackId(self.imp.on_reducer::( + InsertVecIdentityCallbackId(self.imp.on_reducer( "insert_vec_identity", - Box::new(move |ctx: &super::EventContext, args: &InsertVecIdentity| callback(ctx, &args.i)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecIdentity { i }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, i) + }), )) } fn remove_on_insert_vec_identity(&self, callback: InsertVecIdentityCallbackId) { - self.imp - .remove_on_reducer::("insert_vec_identity", callback.0) + self.imp.remove_on_reducer("insert_vec_identity", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_simple_enum_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_simple_enum_reducer.rs index 0590f61e88e..13aeeb7cff7 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_simple_enum_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_simple_enum_reducer.rs @@ -2,25 +2,30 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::simple_enum_type::SimpleEnum; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecSimpleEnum { +pub(super) struct InsertVecSimpleEnumArgs { pub e: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecSimpleEnum { +impl From for super::Reducer { + fn from(args: InsertVecSimpleEnumArgs) -> Self { + Self::InsertVecSimpleEnum { e: args.e } + } +} + +impl __sdk::InModule for InsertVecSimpleEnumArgs { type Module = super::RemoteModule; } -pub struct InsertVecSimpleEnumCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecSimpleEnumCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_simple_enum`. @@ -55,20 +60,32 @@ pub trait insert_vec_simple_enum { impl insert_vec_simple_enum for super::RemoteReducers { fn insert_vec_simple_enum(&self, e: Vec) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_vec_simple_enum", InsertVecSimpleEnum { e }) + .call_reducer("insert_vec_simple_enum", InsertVecSimpleEnumArgs { e }) } fn on_insert_vec_simple_enum( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecSimpleEnumCallbackId { - InsertVecSimpleEnumCallbackId(self.imp.on_reducer::( + InsertVecSimpleEnumCallbackId(self.imp.on_reducer( "insert_vec_simple_enum", - Box::new(move |ctx: &super::EventContext, args: &InsertVecSimpleEnum| callback(ctx, &args.e)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecSimpleEnum { e }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, e) + }), )) } fn remove_on_insert_vec_simple_enum(&self, callback: InsertVecSimpleEnumCallbackId) { - self.imp - .remove_on_reducer::("insert_vec_simple_enum", callback.0) + self.imp.remove_on_reducer("insert_vec_simple_enum", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_string_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_string_reducer.rs index 4f36a761871..09568f9f201 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_string_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_string_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecString { +pub(super) struct InsertVecStringArgs { pub s: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecString { +impl From for super::Reducer { + fn from(args: InsertVecStringArgs) -> Self { + Self::InsertVecString { s: args.s } + } +} + +impl __sdk::InModule for InsertVecStringArgs { type Module = super::RemoteModule; } -pub struct InsertVecStringCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecStringCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_string`. @@ -52,20 +57,32 @@ pub trait insert_vec_string { impl insert_vec_string for super::RemoteReducers { fn insert_vec_string(&self, s: Vec) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_string", InsertVecString { s }) + self.imp.call_reducer("insert_vec_string", InsertVecStringArgs { s }) } fn on_insert_vec_string( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecStringCallbackId { - InsertVecStringCallbackId(self.imp.on_reducer::( + InsertVecStringCallbackId(self.imp.on_reducer( "insert_vec_string", - Box::new(move |ctx: &super::EventContext, args: &InsertVecString| callback(ctx, &args.s)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecString { s }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s) + }), )) } fn remove_on_insert_vec_string(&self, callback: InsertVecStringCallbackId) { - self.imp - .remove_on_reducer::("insert_vec_string", callback.0) + self.imp.remove_on_reducer("insert_vec_string", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_128_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_128_reducer.rs index 0b5f19e7d07..67e144a38b0 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_128_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_128_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecU128 { +pub(super) struct InsertVecU128Args { pub n: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecU128 { +impl From for super::Reducer { + fn from(args: InsertVecU128Args) -> Self { + Self::InsertVecU128 { n: args.n } + } +} + +impl __sdk::InModule for InsertVecU128Args { type Module = super::RemoteModule; } -pub struct InsertVecU128CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecU128CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_u128`. @@ -52,20 +57,32 @@ pub trait insert_vec_u_128 { impl insert_vec_u_128 for super::RemoteReducers { fn insert_vec_u_128(&self, n: Vec) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_u128", InsertVecU128 { n }) + self.imp.call_reducer("insert_vec_u128", InsertVecU128Args { n }) } fn on_insert_vec_u_128( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecU128CallbackId { - InsertVecU128CallbackId(self.imp.on_reducer::( + InsertVecU128CallbackId(self.imp.on_reducer( "insert_vec_u128", - Box::new(move |ctx: &super::EventContext, args: &InsertVecU128| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecU128 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_vec_u_128(&self, callback: InsertVecU128CallbackId) { - self.imp - .remove_on_reducer::("insert_vec_u128", callback.0) + self.imp.remove_on_reducer("insert_vec_u128", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_16_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_16_reducer.rs index d5e35731f9e..e9ebdba5f3c 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_16_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_16_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecU16 { +pub(super) struct InsertVecU16Args { pub n: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecU16 { +impl From for super::Reducer { + fn from(args: InsertVecU16Args) -> Self { + Self::InsertVecU16 { n: args.n } + } +} + +impl __sdk::InModule for InsertVecU16Args { type Module = super::RemoteModule; } -pub struct InsertVecU16CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecU16CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_u16`. @@ -52,19 +57,32 @@ pub trait insert_vec_u_16 { impl insert_vec_u_16 for super::RemoteReducers { fn insert_vec_u_16(&self, n: Vec) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_u16", InsertVecU16 { n }) + self.imp.call_reducer("insert_vec_u16", InsertVecU16Args { n }) } fn on_insert_vec_u_16( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecU16CallbackId { - InsertVecU16CallbackId(self.imp.on_reducer::( + InsertVecU16CallbackId(self.imp.on_reducer( "insert_vec_u16", - Box::new(move |ctx: &super::EventContext, args: &InsertVecU16| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecU16 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_vec_u_16(&self, callback: InsertVecU16CallbackId) { - self.imp.remove_on_reducer::("insert_vec_u16", callback.0) + self.imp.remove_on_reducer("insert_vec_u16", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_256_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_256_reducer.rs index e9039f664f0..da230809020 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_256_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_256_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecU256 { +pub(super) struct InsertVecU256Args { pub n: Vec<__sats::u256>, } -impl __sdk::spacetime_module::InModule for InsertVecU256 { +impl From for super::Reducer { + fn from(args: InsertVecU256Args) -> Self { + Self::InsertVecU256 { n: args.n } + } +} + +impl __sdk::InModule for InsertVecU256Args { type Module = super::RemoteModule; } -pub struct InsertVecU256CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecU256CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_u256`. @@ -52,20 +57,32 @@ pub trait insert_vec_u_256 { impl insert_vec_u_256 for super::RemoteReducers { fn insert_vec_u_256(&self, n: Vec<__sats::u256>) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_u256", InsertVecU256 { n }) + self.imp.call_reducer("insert_vec_u256", InsertVecU256Args { n }) } fn on_insert_vec_u_256( &self, mut callback: impl FnMut(&super::EventContext, &Vec<__sats::u256>) + Send + 'static, ) -> InsertVecU256CallbackId { - InsertVecU256CallbackId(self.imp.on_reducer::( + InsertVecU256CallbackId(self.imp.on_reducer( "insert_vec_u256", - Box::new(move |ctx: &super::EventContext, args: &InsertVecU256| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecU256 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_vec_u_256(&self, callback: InsertVecU256CallbackId) { - self.imp - .remove_on_reducer::("insert_vec_u256", callback.0) + self.imp.remove_on_reducer("insert_vec_u256", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_32_reducer.rs index 805c4eb4527..747cfa50efd 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_32_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecU32 { +pub(super) struct InsertVecU32Args { pub n: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecU32 { +impl From for super::Reducer { + fn from(args: InsertVecU32Args) -> Self { + Self::InsertVecU32 { n: args.n } + } +} + +impl __sdk::InModule for InsertVecU32Args { type Module = super::RemoteModule; } -pub struct InsertVecU32CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecU32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_u32`. @@ -52,19 +57,32 @@ pub trait insert_vec_u_32 { impl insert_vec_u_32 for super::RemoteReducers { fn insert_vec_u_32(&self, n: Vec) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_u32", InsertVecU32 { n }) + self.imp.call_reducer("insert_vec_u32", InsertVecU32Args { n }) } fn on_insert_vec_u_32( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecU32CallbackId { - InsertVecU32CallbackId(self.imp.on_reducer::( + InsertVecU32CallbackId(self.imp.on_reducer( "insert_vec_u32", - Box::new(move |ctx: &super::EventContext, args: &InsertVecU32| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecU32 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_vec_u_32(&self, callback: InsertVecU32CallbackId) { - self.imp.remove_on_reducer::("insert_vec_u32", callback.0) + self.imp.remove_on_reducer("insert_vec_u32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_64_reducer.rs index 4576b20e6b8..05fb5c98cd5 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_64_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecU64 { +pub(super) struct InsertVecU64Args { pub n: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecU64 { +impl From for super::Reducer { + fn from(args: InsertVecU64Args) -> Self { + Self::InsertVecU64 { n: args.n } + } +} + +impl __sdk::InModule for InsertVecU64Args { type Module = super::RemoteModule; } -pub struct InsertVecU64CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecU64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_u64`. @@ -52,19 +57,32 @@ pub trait insert_vec_u_64 { impl insert_vec_u_64 for super::RemoteReducers { fn insert_vec_u_64(&self, n: Vec) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_u64", InsertVecU64 { n }) + self.imp.call_reducer("insert_vec_u64", InsertVecU64Args { n }) } fn on_insert_vec_u_64( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecU64CallbackId { - InsertVecU64CallbackId(self.imp.on_reducer::( + InsertVecU64CallbackId(self.imp.on_reducer( "insert_vec_u64", - Box::new(move |ctx: &super::EventContext, args: &InsertVecU64| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecU64 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_vec_u_64(&self, callback: InsertVecU64CallbackId) { - self.imp.remove_on_reducer::("insert_vec_u64", callback.0) + self.imp.remove_on_reducer("insert_vec_u64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_8_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_8_reducer.rs index 6ba80949e11..e2ddf415dab 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_8_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_u_8_reducer.rs @@ -2,23 +2,28 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecU8 { +pub(super) struct InsertVecU8Args { pub n: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecU8 { +impl From for super::Reducer { + fn from(args: InsertVecU8Args) -> Self { + Self::InsertVecU8 { n: args.n } + } +} + +impl __sdk::InModule for InsertVecU8Args { type Module = super::RemoteModule; } -pub struct InsertVecU8CallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecU8CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_u8`. @@ -52,19 +57,32 @@ pub trait insert_vec_u_8 { impl insert_vec_u_8 for super::RemoteReducers { fn insert_vec_u_8(&self, n: Vec) -> __anyhow::Result<()> { - self.imp.call_reducer("insert_vec_u8", InsertVecU8 { n }) + self.imp.call_reducer("insert_vec_u8", InsertVecU8Args { n }) } fn on_insert_vec_u_8( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecU8CallbackId { - InsertVecU8CallbackId(self.imp.on_reducer::( + InsertVecU8CallbackId(self.imp.on_reducer( "insert_vec_u8", - Box::new(move |ctx: &super::EventContext, args: &InsertVecU8| callback(ctx, &args.n)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecU8 { n }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n) + }), )) } fn remove_on_insert_vec_u_8(&self, callback: InsertVecU8CallbackId) { - self.imp.remove_on_reducer::("insert_vec_u8", callback.0) + self.imp.remove_on_reducer("insert_vec_u8", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_unit_struct_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_unit_struct_reducer.rs index dfb499f11ed..8c3bf8a7d7e 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/insert_vec_unit_struct_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/insert_vec_unit_struct_reducer.rs @@ -2,25 +2,30 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::unit_struct_type::UnitStruct; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct InsertVecUnitStruct { +pub(super) struct InsertVecUnitStructArgs { pub s: Vec, } -impl __sdk::spacetime_module::InModule for InsertVecUnitStruct { +impl From for super::Reducer { + fn from(args: InsertVecUnitStructArgs) -> Self { + Self::InsertVecUnitStruct { s: args.s } + } +} + +impl __sdk::InModule for InsertVecUnitStructArgs { type Module = super::RemoteModule; } -pub struct InsertVecUnitStructCallbackId(__sdk::callbacks::CallbackId); +pub struct InsertVecUnitStructCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `insert_vec_unit_struct`. @@ -55,20 +60,32 @@ pub trait insert_vec_unit_struct { impl insert_vec_unit_struct for super::RemoteReducers { fn insert_vec_unit_struct(&self, s: Vec) -> __anyhow::Result<()> { self.imp - .call_reducer("insert_vec_unit_struct", InsertVecUnitStruct { s }) + .call_reducer("insert_vec_unit_struct", InsertVecUnitStructArgs { s }) } fn on_insert_vec_unit_struct( &self, mut callback: impl FnMut(&super::EventContext, &Vec) + Send + 'static, ) -> InsertVecUnitStructCallbackId { - InsertVecUnitStructCallbackId(self.imp.on_reducer::( + InsertVecUnitStructCallbackId(self.imp.on_reducer( "insert_vec_unit_struct", - Box::new(move |ctx: &super::EventContext, args: &InsertVecUnitStruct| callback(ctx, &args.s)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::InsertVecUnitStruct { s }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s) + }), )) } fn remove_on_insert_vec_unit_struct(&self, callback: InsertVecUnitStructCallbackId) { - self.imp - .remove_on_reducer::("insert_vec_unit_struct", callback.0) + self.imp.remove_on_reducer("insert_vec_unit_struct", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/large_table_table.rs b/crates/sdk/tests/test-client/src/module_bindings/large_table_table.rs index c93d404ac04..b9bbeb4c54d 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/large_table_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/large_table_table.rs @@ -9,10 +9,9 @@ use super::every_vec_struct_type::EveryVecStruct; use super::large_table_type::LargeTable; use super::simple_enum_type::SimpleEnum; use super::unit_struct_type::UnitStruct; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `large_table`. @@ -24,7 +23,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.large_table().on_insert(...)`. pub struct LargeTableTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -47,10 +46,10 @@ impl LargeTableTableAccess for super::RemoteTables { } } -pub struct LargeTableInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct LargeTableDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct LargeTableInsertCallbackId(__sdk::CallbackId); +pub struct LargeTableDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for LargeTableTableHandle<'ctx> { +impl<'ctx> __sdk::Table for LargeTableTableHandle<'ctx> { type Row = LargeTable; type EventContext = super::EventContext; @@ -88,10 +87,14 @@ impl<'ctx> __sdk::table::Table for LargeTableTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("large_table"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"large_table\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/large_table_type.rs b/crates/sdk/tests/test-client/src/module_bindings/large_table_type.rs index 59f56ae1dd6..0e111142960 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/large_table_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/large_table_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::byte_struct_type::ByteStruct; @@ -42,6 +41,6 @@ pub struct LargeTable { pub v: EveryVecStruct, } -impl __sdk::spacetime_module::InModule for LargeTable { +impl __sdk::InModule for LargeTable { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/mod.rs b/crates/sdk/tests/test-client/src/module_bindings/mod.rs index 02caa0e57fa..fc8679bca92 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/mod.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/mod.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; pub mod byte_struct_type; @@ -44,6 +43,10 @@ pub mod delete_unique_u_8_reducer; pub mod enum_with_payload_type; pub mod every_primitive_struct_type; pub mod every_vec_struct_type; +pub mod indexed_table_2_table; +pub mod indexed_table_2_type; +pub mod indexed_table_table; +pub mod indexed_table_type; pub mod insert_caller_one_address_reducer; pub mod insert_caller_one_identity_reducer; pub mod insert_caller_pk_address_reducer; @@ -236,6 +239,9 @@ pub mod pk_u_64_table; pub mod pk_u_64_type; pub mod pk_u_8_table; pub mod pk_u_8_type; +pub mod scheduled_table_table; +pub mod scheduled_table_type; +pub mod send_scheduled_message_reducer; pub mod simple_enum_type; pub mod table_holds_table_table; pub mod table_holds_table_type; @@ -353,353 +359,482 @@ pub mod vec_u_8_type; pub mod vec_unit_struct_table; pub mod vec_unit_struct_type; -pub use byte_struct_type::*; -pub use delete_pk_address_reducer::*; -pub use delete_pk_bool_reducer::*; -pub use delete_pk_i_128_reducer::*; -pub use delete_pk_i_16_reducer::*; -pub use delete_pk_i_256_reducer::*; -pub use delete_pk_i_32_reducer::*; -pub use delete_pk_i_64_reducer::*; -pub use delete_pk_i_8_reducer::*; -pub use delete_pk_identity_reducer::*; -pub use delete_pk_string_reducer::*; -pub use delete_pk_u_128_reducer::*; -pub use delete_pk_u_16_reducer::*; -pub use delete_pk_u_256_reducer::*; -pub use delete_pk_u_32_reducer::*; -pub use delete_pk_u_64_reducer::*; -pub use delete_pk_u_8_reducer::*; -pub use delete_unique_address_reducer::*; -pub use delete_unique_bool_reducer::*; -pub use delete_unique_i_128_reducer::*; -pub use delete_unique_i_16_reducer::*; -pub use delete_unique_i_256_reducer::*; -pub use delete_unique_i_32_reducer::*; -pub use delete_unique_i_64_reducer::*; -pub use delete_unique_i_8_reducer::*; -pub use delete_unique_identity_reducer::*; -pub use delete_unique_string_reducer::*; -pub use delete_unique_u_128_reducer::*; -pub use delete_unique_u_16_reducer::*; -pub use delete_unique_u_256_reducer::*; -pub use delete_unique_u_32_reducer::*; -pub use delete_unique_u_64_reducer::*; -pub use delete_unique_u_8_reducer::*; -pub use enum_with_payload_type::*; -pub use every_primitive_struct_type::*; -pub use every_vec_struct_type::*; -pub use insert_caller_one_address_reducer::*; -pub use insert_caller_one_identity_reducer::*; -pub use insert_caller_pk_address_reducer::*; -pub use insert_caller_pk_identity_reducer::*; -pub use insert_caller_unique_address_reducer::*; -pub use insert_caller_unique_identity_reducer::*; -pub use insert_caller_vec_address_reducer::*; -pub use insert_caller_vec_identity_reducer::*; -pub use insert_large_table_reducer::*; -pub use insert_one_address_reducer::*; -pub use insert_one_bool_reducer::*; -pub use insert_one_byte_struct_reducer::*; -pub use insert_one_enum_with_payload_reducer::*; -pub use insert_one_every_primitive_struct_reducer::*; -pub use insert_one_every_vec_struct_reducer::*; -pub use insert_one_f_32_reducer::*; -pub use insert_one_f_64_reducer::*; -pub use insert_one_i_128_reducer::*; -pub use insert_one_i_16_reducer::*; -pub use insert_one_i_256_reducer::*; -pub use insert_one_i_32_reducer::*; -pub use insert_one_i_64_reducer::*; -pub use insert_one_i_8_reducer::*; -pub use insert_one_identity_reducer::*; -pub use insert_one_simple_enum_reducer::*; -pub use insert_one_string_reducer::*; -pub use insert_one_u_128_reducer::*; -pub use insert_one_u_16_reducer::*; -pub use insert_one_u_256_reducer::*; -pub use insert_one_u_32_reducer::*; -pub use insert_one_u_64_reducer::*; -pub use insert_one_u_8_reducer::*; -pub use insert_one_unit_struct_reducer::*; -pub use insert_option_every_primitive_struct_reducer::*; -pub use insert_option_i_32_reducer::*; -pub use insert_option_identity_reducer::*; -pub use insert_option_simple_enum_reducer::*; -pub use insert_option_string_reducer::*; -pub use insert_option_vec_option_i_32_reducer::*; -pub use insert_pk_address_reducer::*; -pub use insert_pk_bool_reducer::*; -pub use insert_pk_i_128_reducer::*; -pub use insert_pk_i_16_reducer::*; -pub use insert_pk_i_256_reducer::*; -pub use insert_pk_i_32_reducer::*; -pub use insert_pk_i_64_reducer::*; -pub use insert_pk_i_8_reducer::*; -pub use insert_pk_identity_reducer::*; -pub use insert_pk_string_reducer::*; -pub use insert_pk_u_128_reducer::*; -pub use insert_pk_u_16_reducer::*; -pub use insert_pk_u_256_reducer::*; -pub use insert_pk_u_32_reducer::*; -pub use insert_pk_u_64_reducer::*; -pub use insert_pk_u_8_reducer::*; -pub use insert_primitives_as_strings_reducer::*; -pub use insert_table_holds_table_reducer::*; -pub use insert_unique_address_reducer::*; -pub use insert_unique_bool_reducer::*; -pub use insert_unique_i_128_reducer::*; -pub use insert_unique_i_16_reducer::*; -pub use insert_unique_i_256_reducer::*; -pub use insert_unique_i_32_reducer::*; -pub use insert_unique_i_64_reducer::*; -pub use insert_unique_i_8_reducer::*; -pub use insert_unique_identity_reducer::*; -pub use insert_unique_string_reducer::*; -pub use insert_unique_u_128_reducer::*; -pub use insert_unique_u_16_reducer::*; -pub use insert_unique_u_256_reducer::*; -pub use insert_unique_u_32_reducer::*; -pub use insert_unique_u_64_reducer::*; -pub use insert_unique_u_8_reducer::*; -pub use insert_vec_address_reducer::*; -pub use insert_vec_bool_reducer::*; -pub use insert_vec_byte_struct_reducer::*; -pub use insert_vec_enum_with_payload_reducer::*; -pub use insert_vec_every_primitive_struct_reducer::*; -pub use insert_vec_every_vec_struct_reducer::*; -pub use insert_vec_f_32_reducer::*; -pub use insert_vec_f_64_reducer::*; -pub use insert_vec_i_128_reducer::*; -pub use insert_vec_i_16_reducer::*; -pub use insert_vec_i_256_reducer::*; -pub use insert_vec_i_32_reducer::*; -pub use insert_vec_i_64_reducer::*; -pub use insert_vec_i_8_reducer::*; -pub use insert_vec_identity_reducer::*; -pub use insert_vec_simple_enum_reducer::*; -pub use insert_vec_string_reducer::*; -pub use insert_vec_u_128_reducer::*; -pub use insert_vec_u_16_reducer::*; -pub use insert_vec_u_256_reducer::*; -pub use insert_vec_u_32_reducer::*; -pub use insert_vec_u_64_reducer::*; -pub use insert_vec_u_8_reducer::*; -pub use insert_vec_unit_struct_reducer::*; +pub use byte_struct_type::ByteStruct; +pub use delete_pk_address_reducer::{delete_pk_address, set_flags_for_delete_pk_address, DeletePkAddressCallbackId}; +pub use delete_pk_bool_reducer::{delete_pk_bool, set_flags_for_delete_pk_bool, DeletePkBoolCallbackId}; +pub use delete_pk_i_128_reducer::{delete_pk_i_128, set_flags_for_delete_pk_i_128, DeletePkI128CallbackId}; +pub use delete_pk_i_16_reducer::{delete_pk_i_16, set_flags_for_delete_pk_i_16, DeletePkI16CallbackId}; +pub use delete_pk_i_256_reducer::{delete_pk_i_256, set_flags_for_delete_pk_i_256, DeletePkI256CallbackId}; +pub use delete_pk_i_32_reducer::{delete_pk_i_32, set_flags_for_delete_pk_i_32, DeletePkI32CallbackId}; +pub use delete_pk_i_64_reducer::{delete_pk_i_64, set_flags_for_delete_pk_i_64, DeletePkI64CallbackId}; +pub use delete_pk_i_8_reducer::{delete_pk_i_8, set_flags_for_delete_pk_i_8, DeletePkI8CallbackId}; +pub use delete_pk_identity_reducer::{ + delete_pk_identity, set_flags_for_delete_pk_identity, DeletePkIdentityCallbackId, +}; +pub use delete_pk_string_reducer::{delete_pk_string, set_flags_for_delete_pk_string, DeletePkStringCallbackId}; +pub use delete_pk_u_128_reducer::{delete_pk_u_128, set_flags_for_delete_pk_u_128, DeletePkU128CallbackId}; +pub use delete_pk_u_16_reducer::{delete_pk_u_16, set_flags_for_delete_pk_u_16, DeletePkU16CallbackId}; +pub use delete_pk_u_256_reducer::{delete_pk_u_256, set_flags_for_delete_pk_u_256, DeletePkU256CallbackId}; +pub use delete_pk_u_32_reducer::{delete_pk_u_32, set_flags_for_delete_pk_u_32, DeletePkU32CallbackId}; +pub use delete_pk_u_64_reducer::{delete_pk_u_64, set_flags_for_delete_pk_u_64, DeletePkU64CallbackId}; +pub use delete_pk_u_8_reducer::{delete_pk_u_8, set_flags_for_delete_pk_u_8, DeletePkU8CallbackId}; +pub use delete_unique_address_reducer::{ + delete_unique_address, set_flags_for_delete_unique_address, DeleteUniqueAddressCallbackId, +}; +pub use delete_unique_bool_reducer::{ + delete_unique_bool, set_flags_for_delete_unique_bool, DeleteUniqueBoolCallbackId, +}; +pub use delete_unique_i_128_reducer::{ + delete_unique_i_128, set_flags_for_delete_unique_i_128, DeleteUniqueI128CallbackId, +}; +pub use delete_unique_i_16_reducer::{delete_unique_i_16, set_flags_for_delete_unique_i_16, DeleteUniqueI16CallbackId}; +pub use delete_unique_i_256_reducer::{ + delete_unique_i_256, set_flags_for_delete_unique_i_256, DeleteUniqueI256CallbackId, +}; +pub use delete_unique_i_32_reducer::{delete_unique_i_32, set_flags_for_delete_unique_i_32, DeleteUniqueI32CallbackId}; +pub use delete_unique_i_64_reducer::{delete_unique_i_64, set_flags_for_delete_unique_i_64, DeleteUniqueI64CallbackId}; +pub use delete_unique_i_8_reducer::{delete_unique_i_8, set_flags_for_delete_unique_i_8, DeleteUniqueI8CallbackId}; +pub use delete_unique_identity_reducer::{ + delete_unique_identity, set_flags_for_delete_unique_identity, DeleteUniqueIdentityCallbackId, +}; +pub use delete_unique_string_reducer::{ + delete_unique_string, set_flags_for_delete_unique_string, DeleteUniqueStringCallbackId, +}; +pub use delete_unique_u_128_reducer::{ + delete_unique_u_128, set_flags_for_delete_unique_u_128, DeleteUniqueU128CallbackId, +}; +pub use delete_unique_u_16_reducer::{delete_unique_u_16, set_flags_for_delete_unique_u_16, DeleteUniqueU16CallbackId}; +pub use delete_unique_u_256_reducer::{ + delete_unique_u_256, set_flags_for_delete_unique_u_256, DeleteUniqueU256CallbackId, +}; +pub use delete_unique_u_32_reducer::{delete_unique_u_32, set_flags_for_delete_unique_u_32, DeleteUniqueU32CallbackId}; +pub use delete_unique_u_64_reducer::{delete_unique_u_64, set_flags_for_delete_unique_u_64, DeleteUniqueU64CallbackId}; +pub use delete_unique_u_8_reducer::{delete_unique_u_8, set_flags_for_delete_unique_u_8, DeleteUniqueU8CallbackId}; +pub use enum_with_payload_type::EnumWithPayload; +pub use every_primitive_struct_type::EveryPrimitiveStruct; +pub use every_vec_struct_type::EveryVecStruct; +pub use indexed_table_2_table::*; +pub use indexed_table_2_type::IndexedTable2; +pub use indexed_table_table::*; +pub use indexed_table_type::IndexedTable; +pub use insert_caller_one_address_reducer::{ + insert_caller_one_address, set_flags_for_insert_caller_one_address, InsertCallerOneAddressCallbackId, +}; +pub use insert_caller_one_identity_reducer::{ + insert_caller_one_identity, set_flags_for_insert_caller_one_identity, InsertCallerOneIdentityCallbackId, +}; +pub use insert_caller_pk_address_reducer::{ + insert_caller_pk_address, set_flags_for_insert_caller_pk_address, InsertCallerPkAddressCallbackId, +}; +pub use insert_caller_pk_identity_reducer::{ + insert_caller_pk_identity, set_flags_for_insert_caller_pk_identity, InsertCallerPkIdentityCallbackId, +}; +pub use insert_caller_unique_address_reducer::{ + insert_caller_unique_address, set_flags_for_insert_caller_unique_address, InsertCallerUniqueAddressCallbackId, +}; +pub use insert_caller_unique_identity_reducer::{ + insert_caller_unique_identity, set_flags_for_insert_caller_unique_identity, InsertCallerUniqueIdentityCallbackId, +}; +pub use insert_caller_vec_address_reducer::{ + insert_caller_vec_address, set_flags_for_insert_caller_vec_address, InsertCallerVecAddressCallbackId, +}; +pub use insert_caller_vec_identity_reducer::{ + insert_caller_vec_identity, set_flags_for_insert_caller_vec_identity, InsertCallerVecIdentityCallbackId, +}; +pub use insert_large_table_reducer::{ + insert_large_table, set_flags_for_insert_large_table, InsertLargeTableCallbackId, +}; +pub use insert_one_address_reducer::{ + insert_one_address, set_flags_for_insert_one_address, InsertOneAddressCallbackId, +}; +pub use insert_one_bool_reducer::{insert_one_bool, set_flags_for_insert_one_bool, InsertOneBoolCallbackId}; +pub use insert_one_byte_struct_reducer::{ + insert_one_byte_struct, set_flags_for_insert_one_byte_struct, InsertOneByteStructCallbackId, +}; +pub use insert_one_enum_with_payload_reducer::{ + insert_one_enum_with_payload, set_flags_for_insert_one_enum_with_payload, InsertOneEnumWithPayloadCallbackId, +}; +pub use insert_one_every_primitive_struct_reducer::{ + insert_one_every_primitive_struct, set_flags_for_insert_one_every_primitive_struct, + InsertOneEveryPrimitiveStructCallbackId, +}; +pub use insert_one_every_vec_struct_reducer::{ + insert_one_every_vec_struct, set_flags_for_insert_one_every_vec_struct, InsertOneEveryVecStructCallbackId, +}; +pub use insert_one_f_32_reducer::{insert_one_f_32, set_flags_for_insert_one_f_32, InsertOneF32CallbackId}; +pub use insert_one_f_64_reducer::{insert_one_f_64, set_flags_for_insert_one_f_64, InsertOneF64CallbackId}; +pub use insert_one_i_128_reducer::{insert_one_i_128, set_flags_for_insert_one_i_128, InsertOneI128CallbackId}; +pub use insert_one_i_16_reducer::{insert_one_i_16, set_flags_for_insert_one_i_16, InsertOneI16CallbackId}; +pub use insert_one_i_256_reducer::{insert_one_i_256, set_flags_for_insert_one_i_256, InsertOneI256CallbackId}; +pub use insert_one_i_32_reducer::{insert_one_i_32, set_flags_for_insert_one_i_32, InsertOneI32CallbackId}; +pub use insert_one_i_64_reducer::{insert_one_i_64, set_flags_for_insert_one_i_64, InsertOneI64CallbackId}; +pub use insert_one_i_8_reducer::{insert_one_i_8, set_flags_for_insert_one_i_8, InsertOneI8CallbackId}; +pub use insert_one_identity_reducer::{ + insert_one_identity, set_flags_for_insert_one_identity, InsertOneIdentityCallbackId, +}; +pub use insert_one_simple_enum_reducer::{ + insert_one_simple_enum, set_flags_for_insert_one_simple_enum, InsertOneSimpleEnumCallbackId, +}; +pub use insert_one_string_reducer::{insert_one_string, set_flags_for_insert_one_string, InsertOneStringCallbackId}; +pub use insert_one_u_128_reducer::{insert_one_u_128, set_flags_for_insert_one_u_128, InsertOneU128CallbackId}; +pub use insert_one_u_16_reducer::{insert_one_u_16, set_flags_for_insert_one_u_16, InsertOneU16CallbackId}; +pub use insert_one_u_256_reducer::{insert_one_u_256, set_flags_for_insert_one_u_256, InsertOneU256CallbackId}; +pub use insert_one_u_32_reducer::{insert_one_u_32, set_flags_for_insert_one_u_32, InsertOneU32CallbackId}; +pub use insert_one_u_64_reducer::{insert_one_u_64, set_flags_for_insert_one_u_64, InsertOneU64CallbackId}; +pub use insert_one_u_8_reducer::{insert_one_u_8, set_flags_for_insert_one_u_8, InsertOneU8CallbackId}; +pub use insert_one_unit_struct_reducer::{ + insert_one_unit_struct, set_flags_for_insert_one_unit_struct, InsertOneUnitStructCallbackId, +}; +pub use insert_option_every_primitive_struct_reducer::{ + insert_option_every_primitive_struct, set_flags_for_insert_option_every_primitive_struct, + InsertOptionEveryPrimitiveStructCallbackId, +}; +pub use insert_option_i_32_reducer::{insert_option_i_32, set_flags_for_insert_option_i_32, InsertOptionI32CallbackId}; +pub use insert_option_identity_reducer::{ + insert_option_identity, set_flags_for_insert_option_identity, InsertOptionIdentityCallbackId, +}; +pub use insert_option_simple_enum_reducer::{ + insert_option_simple_enum, set_flags_for_insert_option_simple_enum, InsertOptionSimpleEnumCallbackId, +}; +pub use insert_option_string_reducer::{ + insert_option_string, set_flags_for_insert_option_string, InsertOptionStringCallbackId, +}; +pub use insert_option_vec_option_i_32_reducer::{ + insert_option_vec_option_i_32, set_flags_for_insert_option_vec_option_i_32, InsertOptionVecOptionI32CallbackId, +}; +pub use insert_pk_address_reducer::{insert_pk_address, set_flags_for_insert_pk_address, InsertPkAddressCallbackId}; +pub use insert_pk_bool_reducer::{insert_pk_bool, set_flags_for_insert_pk_bool, InsertPkBoolCallbackId}; +pub use insert_pk_i_128_reducer::{insert_pk_i_128, set_flags_for_insert_pk_i_128, InsertPkI128CallbackId}; +pub use insert_pk_i_16_reducer::{insert_pk_i_16, set_flags_for_insert_pk_i_16, InsertPkI16CallbackId}; +pub use insert_pk_i_256_reducer::{insert_pk_i_256, set_flags_for_insert_pk_i_256, InsertPkI256CallbackId}; +pub use insert_pk_i_32_reducer::{insert_pk_i_32, set_flags_for_insert_pk_i_32, InsertPkI32CallbackId}; +pub use insert_pk_i_64_reducer::{insert_pk_i_64, set_flags_for_insert_pk_i_64, InsertPkI64CallbackId}; +pub use insert_pk_i_8_reducer::{insert_pk_i_8, set_flags_for_insert_pk_i_8, InsertPkI8CallbackId}; +pub use insert_pk_identity_reducer::{ + insert_pk_identity, set_flags_for_insert_pk_identity, InsertPkIdentityCallbackId, +}; +pub use insert_pk_string_reducer::{insert_pk_string, set_flags_for_insert_pk_string, InsertPkStringCallbackId}; +pub use insert_pk_u_128_reducer::{insert_pk_u_128, set_flags_for_insert_pk_u_128, InsertPkU128CallbackId}; +pub use insert_pk_u_16_reducer::{insert_pk_u_16, set_flags_for_insert_pk_u_16, InsertPkU16CallbackId}; +pub use insert_pk_u_256_reducer::{insert_pk_u_256, set_flags_for_insert_pk_u_256, InsertPkU256CallbackId}; +pub use insert_pk_u_32_reducer::{insert_pk_u_32, set_flags_for_insert_pk_u_32, InsertPkU32CallbackId}; +pub use insert_pk_u_64_reducer::{insert_pk_u_64, set_flags_for_insert_pk_u_64, InsertPkU64CallbackId}; +pub use insert_pk_u_8_reducer::{insert_pk_u_8, set_flags_for_insert_pk_u_8, InsertPkU8CallbackId}; +pub use insert_primitives_as_strings_reducer::{ + insert_primitives_as_strings, set_flags_for_insert_primitives_as_strings, InsertPrimitivesAsStringsCallbackId, +}; +pub use insert_table_holds_table_reducer::{ + insert_table_holds_table, set_flags_for_insert_table_holds_table, InsertTableHoldsTableCallbackId, +}; +pub use insert_unique_address_reducer::{ + insert_unique_address, set_flags_for_insert_unique_address, InsertUniqueAddressCallbackId, +}; +pub use insert_unique_bool_reducer::{ + insert_unique_bool, set_flags_for_insert_unique_bool, InsertUniqueBoolCallbackId, +}; +pub use insert_unique_i_128_reducer::{ + insert_unique_i_128, set_flags_for_insert_unique_i_128, InsertUniqueI128CallbackId, +}; +pub use insert_unique_i_16_reducer::{insert_unique_i_16, set_flags_for_insert_unique_i_16, InsertUniqueI16CallbackId}; +pub use insert_unique_i_256_reducer::{ + insert_unique_i_256, set_flags_for_insert_unique_i_256, InsertUniqueI256CallbackId, +}; +pub use insert_unique_i_32_reducer::{insert_unique_i_32, set_flags_for_insert_unique_i_32, InsertUniqueI32CallbackId}; +pub use insert_unique_i_64_reducer::{insert_unique_i_64, set_flags_for_insert_unique_i_64, InsertUniqueI64CallbackId}; +pub use insert_unique_i_8_reducer::{insert_unique_i_8, set_flags_for_insert_unique_i_8, InsertUniqueI8CallbackId}; +pub use insert_unique_identity_reducer::{ + insert_unique_identity, set_flags_for_insert_unique_identity, InsertUniqueIdentityCallbackId, +}; +pub use insert_unique_string_reducer::{ + insert_unique_string, set_flags_for_insert_unique_string, InsertUniqueStringCallbackId, +}; +pub use insert_unique_u_128_reducer::{ + insert_unique_u_128, set_flags_for_insert_unique_u_128, InsertUniqueU128CallbackId, +}; +pub use insert_unique_u_16_reducer::{insert_unique_u_16, set_flags_for_insert_unique_u_16, InsertUniqueU16CallbackId}; +pub use insert_unique_u_256_reducer::{ + insert_unique_u_256, set_flags_for_insert_unique_u_256, InsertUniqueU256CallbackId, +}; +pub use insert_unique_u_32_reducer::{insert_unique_u_32, set_flags_for_insert_unique_u_32, InsertUniqueU32CallbackId}; +pub use insert_unique_u_64_reducer::{insert_unique_u_64, set_flags_for_insert_unique_u_64, InsertUniqueU64CallbackId}; +pub use insert_unique_u_8_reducer::{insert_unique_u_8, set_flags_for_insert_unique_u_8, InsertUniqueU8CallbackId}; +pub use insert_vec_address_reducer::{ + insert_vec_address, set_flags_for_insert_vec_address, InsertVecAddressCallbackId, +}; +pub use insert_vec_bool_reducer::{insert_vec_bool, set_flags_for_insert_vec_bool, InsertVecBoolCallbackId}; +pub use insert_vec_byte_struct_reducer::{ + insert_vec_byte_struct, set_flags_for_insert_vec_byte_struct, InsertVecByteStructCallbackId, +}; +pub use insert_vec_enum_with_payload_reducer::{ + insert_vec_enum_with_payload, set_flags_for_insert_vec_enum_with_payload, InsertVecEnumWithPayloadCallbackId, +}; +pub use insert_vec_every_primitive_struct_reducer::{ + insert_vec_every_primitive_struct, set_flags_for_insert_vec_every_primitive_struct, + InsertVecEveryPrimitiveStructCallbackId, +}; +pub use insert_vec_every_vec_struct_reducer::{ + insert_vec_every_vec_struct, set_flags_for_insert_vec_every_vec_struct, InsertVecEveryVecStructCallbackId, +}; +pub use insert_vec_f_32_reducer::{insert_vec_f_32, set_flags_for_insert_vec_f_32, InsertVecF32CallbackId}; +pub use insert_vec_f_64_reducer::{insert_vec_f_64, set_flags_for_insert_vec_f_64, InsertVecF64CallbackId}; +pub use insert_vec_i_128_reducer::{insert_vec_i_128, set_flags_for_insert_vec_i_128, InsertVecI128CallbackId}; +pub use insert_vec_i_16_reducer::{insert_vec_i_16, set_flags_for_insert_vec_i_16, InsertVecI16CallbackId}; +pub use insert_vec_i_256_reducer::{insert_vec_i_256, set_flags_for_insert_vec_i_256, InsertVecI256CallbackId}; +pub use insert_vec_i_32_reducer::{insert_vec_i_32, set_flags_for_insert_vec_i_32, InsertVecI32CallbackId}; +pub use insert_vec_i_64_reducer::{insert_vec_i_64, set_flags_for_insert_vec_i_64, InsertVecI64CallbackId}; +pub use insert_vec_i_8_reducer::{insert_vec_i_8, set_flags_for_insert_vec_i_8, InsertVecI8CallbackId}; +pub use insert_vec_identity_reducer::{ + insert_vec_identity, set_flags_for_insert_vec_identity, InsertVecIdentityCallbackId, +}; +pub use insert_vec_simple_enum_reducer::{ + insert_vec_simple_enum, set_flags_for_insert_vec_simple_enum, InsertVecSimpleEnumCallbackId, +}; +pub use insert_vec_string_reducer::{insert_vec_string, set_flags_for_insert_vec_string, InsertVecStringCallbackId}; +pub use insert_vec_u_128_reducer::{insert_vec_u_128, set_flags_for_insert_vec_u_128, InsertVecU128CallbackId}; +pub use insert_vec_u_16_reducer::{insert_vec_u_16, set_flags_for_insert_vec_u_16, InsertVecU16CallbackId}; +pub use insert_vec_u_256_reducer::{insert_vec_u_256, set_flags_for_insert_vec_u_256, InsertVecU256CallbackId}; +pub use insert_vec_u_32_reducer::{insert_vec_u_32, set_flags_for_insert_vec_u_32, InsertVecU32CallbackId}; +pub use insert_vec_u_64_reducer::{insert_vec_u_64, set_flags_for_insert_vec_u_64, InsertVecU64CallbackId}; +pub use insert_vec_u_8_reducer::{insert_vec_u_8, set_flags_for_insert_vec_u_8, InsertVecU8CallbackId}; +pub use insert_vec_unit_struct_reducer::{ + insert_vec_unit_struct, set_flags_for_insert_vec_unit_struct, InsertVecUnitStructCallbackId, +}; pub use large_table_table::*; -pub use large_table_type::*; -pub use no_op_succeeds_reducer::*; +pub use large_table_type::LargeTable; +pub use no_op_succeeds_reducer::{no_op_succeeds, set_flags_for_no_op_succeeds, NoOpSucceedsCallbackId}; pub use one_address_table::*; -pub use one_address_type::*; +pub use one_address_type::OneAddress; pub use one_bool_table::*; -pub use one_bool_type::*; +pub use one_bool_type::OneBool; pub use one_byte_struct_table::*; -pub use one_byte_struct_type::*; +pub use one_byte_struct_type::OneByteStruct; pub use one_enum_with_payload_table::*; -pub use one_enum_with_payload_type::*; +pub use one_enum_with_payload_type::OneEnumWithPayload; pub use one_every_primitive_struct_table::*; -pub use one_every_primitive_struct_type::*; +pub use one_every_primitive_struct_type::OneEveryPrimitiveStruct; pub use one_every_vec_struct_table::*; -pub use one_every_vec_struct_type::*; +pub use one_every_vec_struct_type::OneEveryVecStruct; pub use one_f_32_table::*; -pub use one_f_32_type::*; +pub use one_f_32_type::OneF32; pub use one_f_64_table::*; -pub use one_f_64_type::*; +pub use one_f_64_type::OneF64; pub use one_i_128_table::*; -pub use one_i_128_type::*; +pub use one_i_128_type::OneI128; pub use one_i_16_table::*; -pub use one_i_16_type::*; +pub use one_i_16_type::OneI16; pub use one_i_256_table::*; -pub use one_i_256_type::*; +pub use one_i_256_type::OneI256; pub use one_i_32_table::*; -pub use one_i_32_type::*; +pub use one_i_32_type::OneI32; pub use one_i_64_table::*; -pub use one_i_64_type::*; +pub use one_i_64_type::OneI64; pub use one_i_8_table::*; -pub use one_i_8_type::*; +pub use one_i_8_type::OneI8; pub use one_identity_table::*; -pub use one_identity_type::*; +pub use one_identity_type::OneIdentity; pub use one_simple_enum_table::*; -pub use one_simple_enum_type::*; +pub use one_simple_enum_type::OneSimpleEnum; pub use one_string_table::*; -pub use one_string_type::*; +pub use one_string_type::OneString; pub use one_u_128_table::*; -pub use one_u_128_type::*; +pub use one_u_128_type::OneU128; pub use one_u_16_table::*; -pub use one_u_16_type::*; +pub use one_u_16_type::OneU16; pub use one_u_256_table::*; -pub use one_u_256_type::*; +pub use one_u_256_type::OneU256; pub use one_u_32_table::*; -pub use one_u_32_type::*; +pub use one_u_32_type::OneU32; pub use one_u_64_table::*; -pub use one_u_64_type::*; +pub use one_u_64_type::OneU64; pub use one_u_8_table::*; -pub use one_u_8_type::*; +pub use one_u_8_type::OneU8; pub use one_unit_struct_table::*; -pub use one_unit_struct_type::*; +pub use one_unit_struct_type::OneUnitStruct; pub use option_every_primitive_struct_table::*; -pub use option_every_primitive_struct_type::*; +pub use option_every_primitive_struct_type::OptionEveryPrimitiveStruct; pub use option_i_32_table::*; -pub use option_i_32_type::*; +pub use option_i_32_type::OptionI32; pub use option_identity_table::*; -pub use option_identity_type::*; +pub use option_identity_type::OptionIdentity; pub use option_simple_enum_table::*; -pub use option_simple_enum_type::*; +pub use option_simple_enum_type::OptionSimpleEnum; pub use option_string_table::*; -pub use option_string_type::*; +pub use option_string_type::OptionString; pub use option_vec_option_i_32_table::*; -pub use option_vec_option_i_32_type::*; +pub use option_vec_option_i_32_type::OptionVecOptionI32; pub use pk_address_table::*; -pub use pk_address_type::*; +pub use pk_address_type::PkAddress; pub use pk_bool_table::*; -pub use pk_bool_type::*; +pub use pk_bool_type::PkBool; pub use pk_i_128_table::*; -pub use pk_i_128_type::*; +pub use pk_i_128_type::PkI128; pub use pk_i_16_table::*; -pub use pk_i_16_type::*; +pub use pk_i_16_type::PkI16; pub use pk_i_256_table::*; -pub use pk_i_256_type::*; +pub use pk_i_256_type::PkI256; pub use pk_i_32_table::*; -pub use pk_i_32_type::*; +pub use pk_i_32_type::PkI32; pub use pk_i_64_table::*; -pub use pk_i_64_type::*; +pub use pk_i_64_type::PkI64; pub use pk_i_8_table::*; -pub use pk_i_8_type::*; +pub use pk_i_8_type::PkI8; pub use pk_identity_table::*; -pub use pk_identity_type::*; +pub use pk_identity_type::PkIdentity; pub use pk_string_table::*; -pub use pk_string_type::*; +pub use pk_string_type::PkString; pub use pk_u_128_table::*; -pub use pk_u_128_type::*; +pub use pk_u_128_type::PkU128; pub use pk_u_16_table::*; -pub use pk_u_16_type::*; +pub use pk_u_16_type::PkU16; pub use pk_u_256_table::*; -pub use pk_u_256_type::*; +pub use pk_u_256_type::PkU256; pub use pk_u_32_table::*; -pub use pk_u_32_type::*; +pub use pk_u_32_type::PkU32; pub use pk_u_64_table::*; -pub use pk_u_64_type::*; +pub use pk_u_64_type::PkU64; pub use pk_u_8_table::*; -pub use pk_u_8_type::*; -pub use simple_enum_type::*; +pub use pk_u_8_type::PkU8; +pub use scheduled_table_table::*; +pub use scheduled_table_type::ScheduledTable; +pub use send_scheduled_message_reducer::{ + send_scheduled_message, set_flags_for_send_scheduled_message, SendScheduledMessageCallbackId, +}; +pub use simple_enum_type::SimpleEnum; pub use table_holds_table_table::*; -pub use table_holds_table_type::*; +pub use table_holds_table_type::TableHoldsTable; pub use unique_address_table::*; -pub use unique_address_type::*; +pub use unique_address_type::UniqueAddress; pub use unique_bool_table::*; -pub use unique_bool_type::*; +pub use unique_bool_type::UniqueBool; pub use unique_i_128_table::*; -pub use unique_i_128_type::*; +pub use unique_i_128_type::UniqueI128; pub use unique_i_16_table::*; -pub use unique_i_16_type::*; +pub use unique_i_16_type::UniqueI16; pub use unique_i_256_table::*; -pub use unique_i_256_type::*; +pub use unique_i_256_type::UniqueI256; pub use unique_i_32_table::*; -pub use unique_i_32_type::*; +pub use unique_i_32_type::UniqueI32; pub use unique_i_64_table::*; -pub use unique_i_64_type::*; +pub use unique_i_64_type::UniqueI64; pub use unique_i_8_table::*; -pub use unique_i_8_type::*; +pub use unique_i_8_type::UniqueI8; pub use unique_identity_table::*; -pub use unique_identity_type::*; +pub use unique_identity_type::UniqueIdentity; pub use unique_string_table::*; -pub use unique_string_type::*; +pub use unique_string_type::UniqueString; pub use unique_u_128_table::*; -pub use unique_u_128_type::*; +pub use unique_u_128_type::UniqueU128; pub use unique_u_16_table::*; -pub use unique_u_16_type::*; +pub use unique_u_16_type::UniqueU16; pub use unique_u_256_table::*; -pub use unique_u_256_type::*; +pub use unique_u_256_type::UniqueU256; pub use unique_u_32_table::*; -pub use unique_u_32_type::*; +pub use unique_u_32_type::UniqueU32; pub use unique_u_64_table::*; -pub use unique_u_64_type::*; +pub use unique_u_64_type::UniqueU64; pub use unique_u_8_table::*; -pub use unique_u_8_type::*; -pub use unit_struct_type::*; -pub use update_pk_address_reducer::*; -pub use update_pk_bool_reducer::*; -pub use update_pk_i_128_reducer::*; -pub use update_pk_i_16_reducer::*; -pub use update_pk_i_256_reducer::*; -pub use update_pk_i_32_reducer::*; -pub use update_pk_i_64_reducer::*; -pub use update_pk_i_8_reducer::*; -pub use update_pk_identity_reducer::*; -pub use update_pk_string_reducer::*; -pub use update_pk_u_128_reducer::*; -pub use update_pk_u_16_reducer::*; -pub use update_pk_u_256_reducer::*; -pub use update_pk_u_32_reducer::*; -pub use update_pk_u_64_reducer::*; -pub use update_pk_u_8_reducer::*; -pub use update_unique_address_reducer::*; -pub use update_unique_bool_reducer::*; -pub use update_unique_i_128_reducer::*; -pub use update_unique_i_16_reducer::*; -pub use update_unique_i_256_reducer::*; -pub use update_unique_i_32_reducer::*; -pub use update_unique_i_64_reducer::*; -pub use update_unique_i_8_reducer::*; -pub use update_unique_identity_reducer::*; -pub use update_unique_string_reducer::*; -pub use update_unique_u_128_reducer::*; -pub use update_unique_u_16_reducer::*; -pub use update_unique_u_256_reducer::*; -pub use update_unique_u_32_reducer::*; -pub use update_unique_u_64_reducer::*; -pub use update_unique_u_8_reducer::*; +pub use unique_u_8_type::UniqueU8; +pub use unit_struct_type::UnitStruct; +pub use update_pk_address_reducer::{set_flags_for_update_pk_address, update_pk_address, UpdatePkAddressCallbackId}; +pub use update_pk_bool_reducer::{set_flags_for_update_pk_bool, update_pk_bool, UpdatePkBoolCallbackId}; +pub use update_pk_i_128_reducer::{set_flags_for_update_pk_i_128, update_pk_i_128, UpdatePkI128CallbackId}; +pub use update_pk_i_16_reducer::{set_flags_for_update_pk_i_16, update_pk_i_16, UpdatePkI16CallbackId}; +pub use update_pk_i_256_reducer::{set_flags_for_update_pk_i_256, update_pk_i_256, UpdatePkI256CallbackId}; +pub use update_pk_i_32_reducer::{set_flags_for_update_pk_i_32, update_pk_i_32, UpdatePkI32CallbackId}; +pub use update_pk_i_64_reducer::{set_flags_for_update_pk_i_64, update_pk_i_64, UpdatePkI64CallbackId}; +pub use update_pk_i_8_reducer::{set_flags_for_update_pk_i_8, update_pk_i_8, UpdatePkI8CallbackId}; +pub use update_pk_identity_reducer::{ + set_flags_for_update_pk_identity, update_pk_identity, UpdatePkIdentityCallbackId, +}; +pub use update_pk_string_reducer::{set_flags_for_update_pk_string, update_pk_string, UpdatePkStringCallbackId}; +pub use update_pk_u_128_reducer::{set_flags_for_update_pk_u_128, update_pk_u_128, UpdatePkU128CallbackId}; +pub use update_pk_u_16_reducer::{set_flags_for_update_pk_u_16, update_pk_u_16, UpdatePkU16CallbackId}; +pub use update_pk_u_256_reducer::{set_flags_for_update_pk_u_256, update_pk_u_256, UpdatePkU256CallbackId}; +pub use update_pk_u_32_reducer::{set_flags_for_update_pk_u_32, update_pk_u_32, UpdatePkU32CallbackId}; +pub use update_pk_u_64_reducer::{set_flags_for_update_pk_u_64, update_pk_u_64, UpdatePkU64CallbackId}; +pub use update_pk_u_8_reducer::{set_flags_for_update_pk_u_8, update_pk_u_8, UpdatePkU8CallbackId}; +pub use update_unique_address_reducer::{ + set_flags_for_update_unique_address, update_unique_address, UpdateUniqueAddressCallbackId, +}; +pub use update_unique_bool_reducer::{ + set_flags_for_update_unique_bool, update_unique_bool, UpdateUniqueBoolCallbackId, +}; +pub use update_unique_i_128_reducer::{ + set_flags_for_update_unique_i_128, update_unique_i_128, UpdateUniqueI128CallbackId, +}; +pub use update_unique_i_16_reducer::{set_flags_for_update_unique_i_16, update_unique_i_16, UpdateUniqueI16CallbackId}; +pub use update_unique_i_256_reducer::{ + set_flags_for_update_unique_i_256, update_unique_i_256, UpdateUniqueI256CallbackId, +}; +pub use update_unique_i_32_reducer::{set_flags_for_update_unique_i_32, update_unique_i_32, UpdateUniqueI32CallbackId}; +pub use update_unique_i_64_reducer::{set_flags_for_update_unique_i_64, update_unique_i_64, UpdateUniqueI64CallbackId}; +pub use update_unique_i_8_reducer::{set_flags_for_update_unique_i_8, update_unique_i_8, UpdateUniqueI8CallbackId}; +pub use update_unique_identity_reducer::{ + set_flags_for_update_unique_identity, update_unique_identity, UpdateUniqueIdentityCallbackId, +}; +pub use update_unique_string_reducer::{ + set_flags_for_update_unique_string, update_unique_string, UpdateUniqueStringCallbackId, +}; +pub use update_unique_u_128_reducer::{ + set_flags_for_update_unique_u_128, update_unique_u_128, UpdateUniqueU128CallbackId, +}; +pub use update_unique_u_16_reducer::{set_flags_for_update_unique_u_16, update_unique_u_16, UpdateUniqueU16CallbackId}; +pub use update_unique_u_256_reducer::{ + set_flags_for_update_unique_u_256, update_unique_u_256, UpdateUniqueU256CallbackId, +}; +pub use update_unique_u_32_reducer::{set_flags_for_update_unique_u_32, update_unique_u_32, UpdateUniqueU32CallbackId}; +pub use update_unique_u_64_reducer::{set_flags_for_update_unique_u_64, update_unique_u_64, UpdateUniqueU64CallbackId}; +pub use update_unique_u_8_reducer::{set_flags_for_update_unique_u_8, update_unique_u_8, UpdateUniqueU8CallbackId}; pub use vec_address_table::*; -pub use vec_address_type::*; +pub use vec_address_type::VecAddress; pub use vec_bool_table::*; -pub use vec_bool_type::*; +pub use vec_bool_type::VecBool; pub use vec_byte_struct_table::*; -pub use vec_byte_struct_type::*; +pub use vec_byte_struct_type::VecByteStruct; pub use vec_enum_with_payload_table::*; -pub use vec_enum_with_payload_type::*; +pub use vec_enum_with_payload_type::VecEnumWithPayload; pub use vec_every_primitive_struct_table::*; -pub use vec_every_primitive_struct_type::*; +pub use vec_every_primitive_struct_type::VecEveryPrimitiveStruct; pub use vec_every_vec_struct_table::*; -pub use vec_every_vec_struct_type::*; +pub use vec_every_vec_struct_type::VecEveryVecStruct; pub use vec_f_32_table::*; -pub use vec_f_32_type::*; +pub use vec_f_32_type::VecF32; pub use vec_f_64_table::*; -pub use vec_f_64_type::*; +pub use vec_f_64_type::VecF64; pub use vec_i_128_table::*; -pub use vec_i_128_type::*; +pub use vec_i_128_type::VecI128; pub use vec_i_16_table::*; -pub use vec_i_16_type::*; +pub use vec_i_16_type::VecI16; pub use vec_i_256_table::*; -pub use vec_i_256_type::*; +pub use vec_i_256_type::VecI256; pub use vec_i_32_table::*; -pub use vec_i_32_type::*; +pub use vec_i_32_type::VecI32; pub use vec_i_64_table::*; -pub use vec_i_64_type::*; +pub use vec_i_64_type::VecI64; pub use vec_i_8_table::*; -pub use vec_i_8_type::*; +pub use vec_i_8_type::VecI8; pub use vec_identity_table::*; -pub use vec_identity_type::*; +pub use vec_identity_type::VecIdentity; pub use vec_simple_enum_table::*; -pub use vec_simple_enum_type::*; +pub use vec_simple_enum_type::VecSimpleEnum; pub use vec_string_table::*; -pub use vec_string_type::*; +pub use vec_string_type::VecString; pub use vec_u_128_table::*; -pub use vec_u_128_type::*; +pub use vec_u_128_type::VecU128; pub use vec_u_16_table::*; -pub use vec_u_16_type::*; +pub use vec_u_16_type::VecU16; pub use vec_u_256_table::*; -pub use vec_u_256_type::*; +pub use vec_u_256_type::VecU256; pub use vec_u_32_table::*; -pub use vec_u_32_type::*; +pub use vec_u_32_type::VecU32; pub use vec_u_64_table::*; -pub use vec_u_64_type::*; +pub use vec_u_64_type::VecU64; pub use vec_u_8_table::*; -pub use vec_u_8_type::*; +pub use vec_u_8_type::VecU8; pub use vec_unit_struct_table::*; -pub use vec_unit_struct_type::*; +pub use vec_unit_struct_type::VecUnitStruct; -#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] -#[sats(crate = __lib)] +#[derive(Clone, PartialEq, Debug)] /// One of the reducers defined by this module. /// @@ -707,505 +842,743 @@ pub use vec_unit_struct_type::*; /// to indicate which reducer caused the event. pub enum Reducer { - DeletePkAddress(delete_pk_address_reducer::DeletePkAddress), - DeletePkBool(delete_pk_bool_reducer::DeletePkBool), - DeletePkI128(delete_pk_i_128_reducer::DeletePkI128), - DeletePkI16(delete_pk_i_16_reducer::DeletePkI16), - DeletePkI256(delete_pk_i_256_reducer::DeletePkI256), - DeletePkI32(delete_pk_i_32_reducer::DeletePkI32), - DeletePkI64(delete_pk_i_64_reducer::DeletePkI64), - DeletePkI8(delete_pk_i_8_reducer::DeletePkI8), - DeletePkIdentity(delete_pk_identity_reducer::DeletePkIdentity), - DeletePkString(delete_pk_string_reducer::DeletePkString), - DeletePkU128(delete_pk_u_128_reducer::DeletePkU128), - DeletePkU16(delete_pk_u_16_reducer::DeletePkU16), - DeletePkU256(delete_pk_u_256_reducer::DeletePkU256), - DeletePkU32(delete_pk_u_32_reducer::DeletePkU32), - DeletePkU64(delete_pk_u_64_reducer::DeletePkU64), - DeletePkU8(delete_pk_u_8_reducer::DeletePkU8), - DeleteUniqueAddress(delete_unique_address_reducer::DeleteUniqueAddress), - DeleteUniqueBool(delete_unique_bool_reducer::DeleteUniqueBool), - DeleteUniqueI128(delete_unique_i_128_reducer::DeleteUniqueI128), - DeleteUniqueI16(delete_unique_i_16_reducer::DeleteUniqueI16), - DeleteUniqueI256(delete_unique_i_256_reducer::DeleteUniqueI256), - DeleteUniqueI32(delete_unique_i_32_reducer::DeleteUniqueI32), - DeleteUniqueI64(delete_unique_i_64_reducer::DeleteUniqueI64), - DeleteUniqueI8(delete_unique_i_8_reducer::DeleteUniqueI8), - DeleteUniqueIdentity(delete_unique_identity_reducer::DeleteUniqueIdentity), - DeleteUniqueString(delete_unique_string_reducer::DeleteUniqueString), - DeleteUniqueU128(delete_unique_u_128_reducer::DeleteUniqueU128), - DeleteUniqueU16(delete_unique_u_16_reducer::DeleteUniqueU16), - DeleteUniqueU256(delete_unique_u_256_reducer::DeleteUniqueU256), - DeleteUniqueU32(delete_unique_u_32_reducer::DeleteUniqueU32), - DeleteUniqueU64(delete_unique_u_64_reducer::DeleteUniqueU64), - DeleteUniqueU8(delete_unique_u_8_reducer::DeleteUniqueU8), - InsertCallerOneAddress(insert_caller_one_address_reducer::InsertCallerOneAddress), - InsertCallerOneIdentity(insert_caller_one_identity_reducer::InsertCallerOneIdentity), - InsertCallerPkAddress(insert_caller_pk_address_reducer::InsertCallerPkAddress), - InsertCallerPkIdentity(insert_caller_pk_identity_reducer::InsertCallerPkIdentity), - InsertCallerUniqueAddress(insert_caller_unique_address_reducer::InsertCallerUniqueAddress), - InsertCallerUniqueIdentity(insert_caller_unique_identity_reducer::InsertCallerUniqueIdentity), - InsertCallerVecAddress(insert_caller_vec_address_reducer::InsertCallerVecAddress), - InsertCallerVecIdentity(insert_caller_vec_identity_reducer::InsertCallerVecIdentity), - InsertLargeTable(insert_large_table_reducer::InsertLargeTable), - InsertOneAddress(insert_one_address_reducer::InsertOneAddress), - InsertOneBool(insert_one_bool_reducer::InsertOneBool), - InsertOneByteStruct(insert_one_byte_struct_reducer::InsertOneByteStruct), - InsertOneEnumWithPayload(insert_one_enum_with_payload_reducer::InsertOneEnumWithPayload), - InsertOneEveryPrimitiveStruct(insert_one_every_primitive_struct_reducer::InsertOneEveryPrimitiveStruct), - InsertOneEveryVecStruct(insert_one_every_vec_struct_reducer::InsertOneEveryVecStruct), - InsertOneF32(insert_one_f_32_reducer::InsertOneF32), - InsertOneF64(insert_one_f_64_reducer::InsertOneF64), - InsertOneI128(insert_one_i_128_reducer::InsertOneI128), - InsertOneI16(insert_one_i_16_reducer::InsertOneI16), - InsertOneI256(insert_one_i_256_reducer::InsertOneI256), - InsertOneI32(insert_one_i_32_reducer::InsertOneI32), - InsertOneI64(insert_one_i_64_reducer::InsertOneI64), - InsertOneI8(insert_one_i_8_reducer::InsertOneI8), - InsertOneIdentity(insert_one_identity_reducer::InsertOneIdentity), - InsertOneSimpleEnum(insert_one_simple_enum_reducer::InsertOneSimpleEnum), - InsertOneString(insert_one_string_reducer::InsertOneString), - InsertOneU128(insert_one_u_128_reducer::InsertOneU128), - InsertOneU16(insert_one_u_16_reducer::InsertOneU16), - InsertOneU256(insert_one_u_256_reducer::InsertOneU256), - InsertOneU32(insert_one_u_32_reducer::InsertOneU32), - InsertOneU64(insert_one_u_64_reducer::InsertOneU64), - InsertOneU8(insert_one_u_8_reducer::InsertOneU8), - InsertOneUnitStruct(insert_one_unit_struct_reducer::InsertOneUnitStruct), - InsertOptionEveryPrimitiveStruct(insert_option_every_primitive_struct_reducer::InsertOptionEveryPrimitiveStruct), - InsertOptionI32(insert_option_i_32_reducer::InsertOptionI32), - InsertOptionIdentity(insert_option_identity_reducer::InsertOptionIdentity), - InsertOptionSimpleEnum(insert_option_simple_enum_reducer::InsertOptionSimpleEnum), - InsertOptionString(insert_option_string_reducer::InsertOptionString), - InsertOptionVecOptionI32(insert_option_vec_option_i_32_reducer::InsertOptionVecOptionI32), - InsertPkAddress(insert_pk_address_reducer::InsertPkAddress), - InsertPkBool(insert_pk_bool_reducer::InsertPkBool), - InsertPkI128(insert_pk_i_128_reducer::InsertPkI128), - InsertPkI16(insert_pk_i_16_reducer::InsertPkI16), - InsertPkI256(insert_pk_i_256_reducer::InsertPkI256), - InsertPkI32(insert_pk_i_32_reducer::InsertPkI32), - InsertPkI64(insert_pk_i_64_reducer::InsertPkI64), - InsertPkI8(insert_pk_i_8_reducer::InsertPkI8), - InsertPkIdentity(insert_pk_identity_reducer::InsertPkIdentity), - InsertPkString(insert_pk_string_reducer::InsertPkString), - InsertPkU128(insert_pk_u_128_reducer::InsertPkU128), - InsertPkU16(insert_pk_u_16_reducer::InsertPkU16), - InsertPkU256(insert_pk_u_256_reducer::InsertPkU256), - InsertPkU32(insert_pk_u_32_reducer::InsertPkU32), - InsertPkU64(insert_pk_u_64_reducer::InsertPkU64), - InsertPkU8(insert_pk_u_8_reducer::InsertPkU8), - InsertPrimitivesAsStrings(insert_primitives_as_strings_reducer::InsertPrimitivesAsStrings), - InsertTableHoldsTable(insert_table_holds_table_reducer::InsertTableHoldsTable), - InsertUniqueAddress(insert_unique_address_reducer::InsertUniqueAddress), - InsertUniqueBool(insert_unique_bool_reducer::InsertUniqueBool), - InsertUniqueI128(insert_unique_i_128_reducer::InsertUniqueI128), - InsertUniqueI16(insert_unique_i_16_reducer::InsertUniqueI16), - InsertUniqueI256(insert_unique_i_256_reducer::InsertUniqueI256), - InsertUniqueI32(insert_unique_i_32_reducer::InsertUniqueI32), - InsertUniqueI64(insert_unique_i_64_reducer::InsertUniqueI64), - InsertUniqueI8(insert_unique_i_8_reducer::InsertUniqueI8), - InsertUniqueIdentity(insert_unique_identity_reducer::InsertUniqueIdentity), - InsertUniqueString(insert_unique_string_reducer::InsertUniqueString), - InsertUniqueU128(insert_unique_u_128_reducer::InsertUniqueU128), - InsertUniqueU16(insert_unique_u_16_reducer::InsertUniqueU16), - InsertUniqueU256(insert_unique_u_256_reducer::InsertUniqueU256), - InsertUniqueU32(insert_unique_u_32_reducer::InsertUniqueU32), - InsertUniqueU64(insert_unique_u_64_reducer::InsertUniqueU64), - InsertUniqueU8(insert_unique_u_8_reducer::InsertUniqueU8), - InsertVecAddress(insert_vec_address_reducer::InsertVecAddress), - InsertVecBool(insert_vec_bool_reducer::InsertVecBool), - InsertVecByteStruct(insert_vec_byte_struct_reducer::InsertVecByteStruct), - InsertVecEnumWithPayload(insert_vec_enum_with_payload_reducer::InsertVecEnumWithPayload), - InsertVecEveryPrimitiveStruct(insert_vec_every_primitive_struct_reducer::InsertVecEveryPrimitiveStruct), - InsertVecEveryVecStruct(insert_vec_every_vec_struct_reducer::InsertVecEveryVecStruct), - InsertVecF32(insert_vec_f_32_reducer::InsertVecF32), - InsertVecF64(insert_vec_f_64_reducer::InsertVecF64), - InsertVecI128(insert_vec_i_128_reducer::InsertVecI128), - InsertVecI16(insert_vec_i_16_reducer::InsertVecI16), - InsertVecI256(insert_vec_i_256_reducer::InsertVecI256), - InsertVecI32(insert_vec_i_32_reducer::InsertVecI32), - InsertVecI64(insert_vec_i_64_reducer::InsertVecI64), - InsertVecI8(insert_vec_i_8_reducer::InsertVecI8), - InsertVecIdentity(insert_vec_identity_reducer::InsertVecIdentity), - InsertVecSimpleEnum(insert_vec_simple_enum_reducer::InsertVecSimpleEnum), - InsertVecString(insert_vec_string_reducer::InsertVecString), - InsertVecU128(insert_vec_u_128_reducer::InsertVecU128), - InsertVecU16(insert_vec_u_16_reducer::InsertVecU16), - InsertVecU256(insert_vec_u_256_reducer::InsertVecU256), - InsertVecU32(insert_vec_u_32_reducer::InsertVecU32), - InsertVecU64(insert_vec_u_64_reducer::InsertVecU64), - InsertVecU8(insert_vec_u_8_reducer::InsertVecU8), - InsertVecUnitStruct(insert_vec_unit_struct_reducer::InsertVecUnitStruct), - NoOpSucceeds(no_op_succeeds_reducer::NoOpSucceeds), - UpdatePkAddress(update_pk_address_reducer::UpdatePkAddress), - UpdatePkBool(update_pk_bool_reducer::UpdatePkBool), - UpdatePkI128(update_pk_i_128_reducer::UpdatePkI128), - UpdatePkI16(update_pk_i_16_reducer::UpdatePkI16), - UpdatePkI256(update_pk_i_256_reducer::UpdatePkI256), - UpdatePkI32(update_pk_i_32_reducer::UpdatePkI32), - UpdatePkI64(update_pk_i_64_reducer::UpdatePkI64), - UpdatePkI8(update_pk_i_8_reducer::UpdatePkI8), - UpdatePkIdentity(update_pk_identity_reducer::UpdatePkIdentity), - UpdatePkString(update_pk_string_reducer::UpdatePkString), - UpdatePkU128(update_pk_u_128_reducer::UpdatePkU128), - UpdatePkU16(update_pk_u_16_reducer::UpdatePkU16), - UpdatePkU256(update_pk_u_256_reducer::UpdatePkU256), - UpdatePkU32(update_pk_u_32_reducer::UpdatePkU32), - UpdatePkU64(update_pk_u_64_reducer::UpdatePkU64), - UpdatePkU8(update_pk_u_8_reducer::UpdatePkU8), - UpdateUniqueAddress(update_unique_address_reducer::UpdateUniqueAddress), - UpdateUniqueBool(update_unique_bool_reducer::UpdateUniqueBool), - UpdateUniqueI128(update_unique_i_128_reducer::UpdateUniqueI128), - UpdateUniqueI16(update_unique_i_16_reducer::UpdateUniqueI16), - UpdateUniqueI256(update_unique_i_256_reducer::UpdateUniqueI256), - UpdateUniqueI32(update_unique_i_32_reducer::UpdateUniqueI32), - UpdateUniqueI64(update_unique_i_64_reducer::UpdateUniqueI64), - UpdateUniqueI8(update_unique_i_8_reducer::UpdateUniqueI8), - UpdateUniqueIdentity(update_unique_identity_reducer::UpdateUniqueIdentity), - UpdateUniqueString(update_unique_string_reducer::UpdateUniqueString), - UpdateUniqueU128(update_unique_u_128_reducer::UpdateUniqueU128), - UpdateUniqueU16(update_unique_u_16_reducer::UpdateUniqueU16), - UpdateUniqueU256(update_unique_u_256_reducer::UpdateUniqueU256), - UpdateUniqueU32(update_unique_u_32_reducer::UpdateUniqueU32), - UpdateUniqueU64(update_unique_u_64_reducer::UpdateUniqueU64), - UpdateUniqueU8(update_unique_u_8_reducer::UpdateUniqueU8), + DeletePkAddress { + a: __sdk::Address, + }, + DeletePkBool { + b: bool, + }, + DeletePkI128 { + n: i128, + }, + DeletePkI16 { + n: i16, + }, + DeletePkI256 { + n: __sats::i256, + }, + DeletePkI32 { + n: i32, + }, + DeletePkI64 { + n: i64, + }, + DeletePkI8 { + n: i8, + }, + DeletePkIdentity { + i: __sdk::Identity, + }, + DeletePkString { + s: String, + }, + DeletePkU128 { + n: u128, + }, + DeletePkU16 { + n: u16, + }, + DeletePkU256 { + n: __sats::u256, + }, + DeletePkU32 { + n: u32, + }, + DeletePkU64 { + n: u64, + }, + DeletePkU8 { + n: u8, + }, + DeleteUniqueAddress { + a: __sdk::Address, + }, + DeleteUniqueBool { + b: bool, + }, + DeleteUniqueI128 { + n: i128, + }, + DeleteUniqueI16 { + n: i16, + }, + DeleteUniqueI256 { + n: __sats::i256, + }, + DeleteUniqueI32 { + n: i32, + }, + DeleteUniqueI64 { + n: i64, + }, + DeleteUniqueI8 { + n: i8, + }, + DeleteUniqueIdentity { + i: __sdk::Identity, + }, + DeleteUniqueString { + s: String, + }, + DeleteUniqueU128 { + n: u128, + }, + DeleteUniqueU16 { + n: u16, + }, + DeleteUniqueU256 { + n: __sats::u256, + }, + DeleteUniqueU32 { + n: u32, + }, + DeleteUniqueU64 { + n: u64, + }, + DeleteUniqueU8 { + n: u8, + }, + InsertCallerOneAddress, + InsertCallerOneIdentity, + InsertCallerPkAddress { + data: i32, + }, + InsertCallerPkIdentity { + data: i32, + }, + InsertCallerUniqueAddress { + data: i32, + }, + InsertCallerUniqueIdentity { + data: i32, + }, + InsertCallerVecAddress, + InsertCallerVecIdentity, + InsertLargeTable { + a: u8, + b: u16, + c: u32, + d: u64, + e: u128, + f: __sats::u256, + g: i8, + h: i16, + i: i32, + j: i64, + k: i128, + l: __sats::i256, + m: bool, + n: f32, + o: f64, + p: String, + q: SimpleEnum, + r: EnumWithPayload, + s: UnitStruct, + t: ByteStruct, + u: EveryPrimitiveStruct, + v: EveryVecStruct, + }, + InsertOneAddress { + a: __sdk::Address, + }, + InsertOneBool { + b: bool, + }, + InsertOneByteStruct { + s: ByteStruct, + }, + InsertOneEnumWithPayload { + e: EnumWithPayload, + }, + InsertOneEveryPrimitiveStruct { + s: EveryPrimitiveStruct, + }, + InsertOneEveryVecStruct { + s: EveryVecStruct, + }, + InsertOneF32 { + f: f32, + }, + InsertOneF64 { + f: f64, + }, + InsertOneI128 { + n: i128, + }, + InsertOneI16 { + n: i16, + }, + InsertOneI256 { + n: __sats::i256, + }, + InsertOneI32 { + n: i32, + }, + InsertOneI64 { + n: i64, + }, + InsertOneI8 { + n: i8, + }, + InsertOneIdentity { + i: __sdk::Identity, + }, + InsertOneSimpleEnum { + e: SimpleEnum, + }, + InsertOneString { + s: String, + }, + InsertOneU128 { + n: u128, + }, + InsertOneU16 { + n: u16, + }, + InsertOneU256 { + n: __sats::u256, + }, + InsertOneU32 { + n: u32, + }, + InsertOneU64 { + n: u64, + }, + InsertOneU8 { + n: u8, + }, + InsertOneUnitStruct { + s: UnitStruct, + }, + InsertOptionEveryPrimitiveStruct { + s: Option, + }, + InsertOptionI32 { + n: Option, + }, + InsertOptionIdentity { + i: Option<__sdk::Identity>, + }, + InsertOptionSimpleEnum { + e: Option, + }, + InsertOptionString { + s: Option, + }, + InsertOptionVecOptionI32 { + v: Option>>, + }, + InsertPkAddress { + a: __sdk::Address, + data: i32, + }, + InsertPkBool { + b: bool, + data: i32, + }, + InsertPkI128 { + n: i128, + data: i32, + }, + InsertPkI16 { + n: i16, + data: i32, + }, + InsertPkI256 { + n: __sats::i256, + data: i32, + }, + InsertPkI32 { + n: i32, + data: i32, + }, + InsertPkI64 { + n: i64, + data: i32, + }, + InsertPkI8 { + n: i8, + data: i32, + }, + InsertPkIdentity { + i: __sdk::Identity, + data: i32, + }, + InsertPkString { + s: String, + data: i32, + }, + InsertPkU128 { + n: u128, + data: i32, + }, + InsertPkU16 { + n: u16, + data: i32, + }, + InsertPkU256 { + n: __sats::u256, + data: i32, + }, + InsertPkU32 { + n: u32, + data: i32, + }, + InsertPkU64 { + n: u64, + data: i32, + }, + InsertPkU8 { + n: u8, + data: i32, + }, + InsertPrimitivesAsStrings { + s: EveryPrimitiveStruct, + }, + InsertTableHoldsTable { + a: OneU8, + b: VecU8, + }, + InsertUniqueAddress { + a: __sdk::Address, + data: i32, + }, + InsertUniqueBool { + b: bool, + data: i32, + }, + InsertUniqueI128 { + n: i128, + data: i32, + }, + InsertUniqueI16 { + n: i16, + data: i32, + }, + InsertUniqueI256 { + n: __sats::i256, + data: i32, + }, + InsertUniqueI32 { + n: i32, + data: i32, + }, + InsertUniqueI64 { + n: i64, + data: i32, + }, + InsertUniqueI8 { + n: i8, + data: i32, + }, + InsertUniqueIdentity { + i: __sdk::Identity, + data: i32, + }, + InsertUniqueString { + s: String, + data: i32, + }, + InsertUniqueU128 { + n: u128, + data: i32, + }, + InsertUniqueU16 { + n: u16, + data: i32, + }, + InsertUniqueU256 { + n: __sats::u256, + data: i32, + }, + InsertUniqueU32 { + n: u32, + data: i32, + }, + InsertUniqueU64 { + n: u64, + data: i32, + }, + InsertUniqueU8 { + n: u8, + data: i32, + }, + InsertVecAddress { + a: Vec<__sdk::Address>, + }, + InsertVecBool { + b: Vec, + }, + InsertVecByteStruct { + s: Vec, + }, + InsertVecEnumWithPayload { + e: Vec, + }, + InsertVecEveryPrimitiveStruct { + s: Vec, + }, + InsertVecEveryVecStruct { + s: Vec, + }, + InsertVecF32 { + f: Vec, + }, + InsertVecF64 { + f: Vec, + }, + InsertVecI128 { + n: Vec, + }, + InsertVecI16 { + n: Vec, + }, + InsertVecI256 { + n: Vec<__sats::i256>, + }, + InsertVecI32 { + n: Vec, + }, + InsertVecI64 { + n: Vec, + }, + InsertVecI8 { + n: Vec, + }, + InsertVecIdentity { + i: Vec<__sdk::Identity>, + }, + InsertVecSimpleEnum { + e: Vec, + }, + InsertVecString { + s: Vec, + }, + InsertVecU128 { + n: Vec, + }, + InsertVecU16 { + n: Vec, + }, + InsertVecU256 { + n: Vec<__sats::u256>, + }, + InsertVecU32 { + n: Vec, + }, + InsertVecU64 { + n: Vec, + }, + InsertVecU8 { + n: Vec, + }, + InsertVecUnitStruct { + s: Vec, + }, + NoOpSucceeds, + SendScheduledMessage { + arg: ScheduledTable, + }, + UpdatePkAddress { + a: __sdk::Address, + data: i32, + }, + UpdatePkBool { + b: bool, + data: i32, + }, + UpdatePkI128 { + n: i128, + data: i32, + }, + UpdatePkI16 { + n: i16, + data: i32, + }, + UpdatePkI256 { + n: __sats::i256, + data: i32, + }, + UpdatePkI32 { + n: i32, + data: i32, + }, + UpdatePkI64 { + n: i64, + data: i32, + }, + UpdatePkI8 { + n: i8, + data: i32, + }, + UpdatePkIdentity { + i: __sdk::Identity, + data: i32, + }, + UpdatePkString { + s: String, + data: i32, + }, + UpdatePkU128 { + n: u128, + data: i32, + }, + UpdatePkU16 { + n: u16, + data: i32, + }, + UpdatePkU256 { + n: __sats::u256, + data: i32, + }, + UpdatePkU32 { + n: u32, + data: i32, + }, + UpdatePkU64 { + n: u64, + data: i32, + }, + UpdatePkU8 { + n: u8, + data: i32, + }, + UpdateUniqueAddress { + a: __sdk::Address, + data: i32, + }, + UpdateUniqueBool { + b: bool, + data: i32, + }, + UpdateUniqueI128 { + n: i128, + data: i32, + }, + UpdateUniqueI16 { + n: i16, + data: i32, + }, + UpdateUniqueI256 { + n: __sats::i256, + data: i32, + }, + UpdateUniqueI32 { + n: i32, + data: i32, + }, + UpdateUniqueI64 { + n: i64, + data: i32, + }, + UpdateUniqueI8 { + n: i8, + data: i32, + }, + UpdateUniqueIdentity { + i: __sdk::Identity, + data: i32, + }, + UpdateUniqueString { + s: String, + data: i32, + }, + UpdateUniqueU128 { + n: u128, + data: i32, + }, + UpdateUniqueU16 { + n: u16, + data: i32, + }, + UpdateUniqueU256 { + n: __sats::u256, + data: i32, + }, + UpdateUniqueU32 { + n: u32, + data: i32, + }, + UpdateUniqueU64 { + n: u64, + data: i32, + }, + UpdateUniqueU8 { + n: u8, + data: i32, + }, } -impl __sdk::spacetime_module::InModule for Reducer { +impl __sdk::InModule for Reducer { type Module = RemoteModule; } -impl __sdk::spacetime_module::Reducer for Reducer { +impl __sdk::Reducer for Reducer { fn reducer_name(&self) -> &'static str { match self { - Reducer::DeletePkAddress(_) => "delete_pk_address", - Reducer::DeletePkBool(_) => "delete_pk_bool", - Reducer::DeletePkI128(_) => "delete_pk_i128", - Reducer::DeletePkI16(_) => "delete_pk_i16", - Reducer::DeletePkI256(_) => "delete_pk_i256", - Reducer::DeletePkI32(_) => "delete_pk_i32", - Reducer::DeletePkI64(_) => "delete_pk_i64", - Reducer::DeletePkI8(_) => "delete_pk_i8", - Reducer::DeletePkIdentity(_) => "delete_pk_identity", - Reducer::DeletePkString(_) => "delete_pk_string", - Reducer::DeletePkU128(_) => "delete_pk_u128", - Reducer::DeletePkU16(_) => "delete_pk_u16", - Reducer::DeletePkU256(_) => "delete_pk_u256", - Reducer::DeletePkU32(_) => "delete_pk_u32", - Reducer::DeletePkU64(_) => "delete_pk_u64", - Reducer::DeletePkU8(_) => "delete_pk_u8", - Reducer::DeleteUniqueAddress(_) => "delete_unique_address", - Reducer::DeleteUniqueBool(_) => "delete_unique_bool", - Reducer::DeleteUniqueI128(_) => "delete_unique_i128", - Reducer::DeleteUniqueI16(_) => "delete_unique_i16", - Reducer::DeleteUniqueI256(_) => "delete_unique_i256", - Reducer::DeleteUniqueI32(_) => "delete_unique_i32", - Reducer::DeleteUniqueI64(_) => "delete_unique_i64", - Reducer::DeleteUniqueI8(_) => "delete_unique_i8", - Reducer::DeleteUniqueIdentity(_) => "delete_unique_identity", - Reducer::DeleteUniqueString(_) => "delete_unique_string", - Reducer::DeleteUniqueU128(_) => "delete_unique_u128", - Reducer::DeleteUniqueU16(_) => "delete_unique_u16", - Reducer::DeleteUniqueU256(_) => "delete_unique_u256", - Reducer::DeleteUniqueU32(_) => "delete_unique_u32", - Reducer::DeleteUniqueU64(_) => "delete_unique_u64", - Reducer::DeleteUniqueU8(_) => "delete_unique_u8", - Reducer::InsertCallerOneAddress(_) => "insert_caller_one_address", - Reducer::InsertCallerOneIdentity(_) => "insert_caller_one_identity", - Reducer::InsertCallerPkAddress(_) => "insert_caller_pk_address", - Reducer::InsertCallerPkIdentity(_) => "insert_caller_pk_identity", - Reducer::InsertCallerUniqueAddress(_) => "insert_caller_unique_address", - Reducer::InsertCallerUniqueIdentity(_) => "insert_caller_unique_identity", - Reducer::InsertCallerVecAddress(_) => "insert_caller_vec_address", - Reducer::InsertCallerVecIdentity(_) => "insert_caller_vec_identity", - Reducer::InsertLargeTable(_) => "insert_large_table", - Reducer::InsertOneAddress(_) => "insert_one_address", - Reducer::InsertOneBool(_) => "insert_one_bool", - Reducer::InsertOneByteStruct(_) => "insert_one_byte_struct", - Reducer::InsertOneEnumWithPayload(_) => "insert_one_enum_with_payload", - Reducer::InsertOneEveryPrimitiveStruct(_) => "insert_one_every_primitive_struct", - Reducer::InsertOneEveryVecStruct(_) => "insert_one_every_vec_struct", - Reducer::InsertOneF32(_) => "insert_one_f32", - Reducer::InsertOneF64(_) => "insert_one_f64", - Reducer::InsertOneI128(_) => "insert_one_i128", - Reducer::InsertOneI16(_) => "insert_one_i16", - Reducer::InsertOneI256(_) => "insert_one_i256", - Reducer::InsertOneI32(_) => "insert_one_i32", - Reducer::InsertOneI64(_) => "insert_one_i64", - Reducer::InsertOneI8(_) => "insert_one_i8", - Reducer::InsertOneIdentity(_) => "insert_one_identity", - Reducer::InsertOneSimpleEnum(_) => "insert_one_simple_enum", - Reducer::InsertOneString(_) => "insert_one_string", - Reducer::InsertOneU128(_) => "insert_one_u128", - Reducer::InsertOneU16(_) => "insert_one_u16", - Reducer::InsertOneU256(_) => "insert_one_u256", - Reducer::InsertOneU32(_) => "insert_one_u32", - Reducer::InsertOneU64(_) => "insert_one_u64", - Reducer::InsertOneU8(_) => "insert_one_u8", - Reducer::InsertOneUnitStruct(_) => "insert_one_unit_struct", - Reducer::InsertOptionEveryPrimitiveStruct(_) => "insert_option_every_primitive_struct", - Reducer::InsertOptionI32(_) => "insert_option_i32", - Reducer::InsertOptionIdentity(_) => "insert_option_identity", - Reducer::InsertOptionSimpleEnum(_) => "insert_option_simple_enum", - Reducer::InsertOptionString(_) => "insert_option_string", - Reducer::InsertOptionVecOptionI32(_) => "insert_option_vec_option_i32", - Reducer::InsertPkAddress(_) => "insert_pk_address", - Reducer::InsertPkBool(_) => "insert_pk_bool", - Reducer::InsertPkI128(_) => "insert_pk_i128", - Reducer::InsertPkI16(_) => "insert_pk_i16", - Reducer::InsertPkI256(_) => "insert_pk_i256", - Reducer::InsertPkI32(_) => "insert_pk_i32", - Reducer::InsertPkI64(_) => "insert_pk_i64", - Reducer::InsertPkI8(_) => "insert_pk_i8", - Reducer::InsertPkIdentity(_) => "insert_pk_identity", - Reducer::InsertPkString(_) => "insert_pk_string", - Reducer::InsertPkU128(_) => "insert_pk_u128", - Reducer::InsertPkU16(_) => "insert_pk_u16", - Reducer::InsertPkU256(_) => "insert_pk_u256", - Reducer::InsertPkU32(_) => "insert_pk_u32", - Reducer::InsertPkU64(_) => "insert_pk_u64", - Reducer::InsertPkU8(_) => "insert_pk_u8", - Reducer::InsertPrimitivesAsStrings(_) => "insert_primitives_as_strings", - Reducer::InsertTableHoldsTable(_) => "insert_table_holds_table", - Reducer::InsertUniqueAddress(_) => "insert_unique_address", - Reducer::InsertUniqueBool(_) => "insert_unique_bool", - Reducer::InsertUniqueI128(_) => "insert_unique_i128", - Reducer::InsertUniqueI16(_) => "insert_unique_i16", - Reducer::InsertUniqueI256(_) => "insert_unique_i256", - Reducer::InsertUniqueI32(_) => "insert_unique_i32", - Reducer::InsertUniqueI64(_) => "insert_unique_i64", - Reducer::InsertUniqueI8(_) => "insert_unique_i8", - Reducer::InsertUniqueIdentity(_) => "insert_unique_identity", - Reducer::InsertUniqueString(_) => "insert_unique_string", - Reducer::InsertUniqueU128(_) => "insert_unique_u128", - Reducer::InsertUniqueU16(_) => "insert_unique_u16", - Reducer::InsertUniqueU256(_) => "insert_unique_u256", - Reducer::InsertUniqueU32(_) => "insert_unique_u32", - Reducer::InsertUniqueU64(_) => "insert_unique_u64", - Reducer::InsertUniqueU8(_) => "insert_unique_u8", - Reducer::InsertVecAddress(_) => "insert_vec_address", - Reducer::InsertVecBool(_) => "insert_vec_bool", - Reducer::InsertVecByteStruct(_) => "insert_vec_byte_struct", - Reducer::InsertVecEnumWithPayload(_) => "insert_vec_enum_with_payload", - Reducer::InsertVecEveryPrimitiveStruct(_) => "insert_vec_every_primitive_struct", - Reducer::InsertVecEveryVecStruct(_) => "insert_vec_every_vec_struct", - Reducer::InsertVecF32(_) => "insert_vec_f32", - Reducer::InsertVecF64(_) => "insert_vec_f64", - Reducer::InsertVecI128(_) => "insert_vec_i128", - Reducer::InsertVecI16(_) => "insert_vec_i16", - Reducer::InsertVecI256(_) => "insert_vec_i256", - Reducer::InsertVecI32(_) => "insert_vec_i32", - Reducer::InsertVecI64(_) => "insert_vec_i64", - Reducer::InsertVecI8(_) => "insert_vec_i8", - Reducer::InsertVecIdentity(_) => "insert_vec_identity", - Reducer::InsertVecSimpleEnum(_) => "insert_vec_simple_enum", - Reducer::InsertVecString(_) => "insert_vec_string", - Reducer::InsertVecU128(_) => "insert_vec_u128", - Reducer::InsertVecU16(_) => "insert_vec_u16", - Reducer::InsertVecU256(_) => "insert_vec_u256", - Reducer::InsertVecU32(_) => "insert_vec_u32", - Reducer::InsertVecU64(_) => "insert_vec_u64", - Reducer::InsertVecU8(_) => "insert_vec_u8", - Reducer::InsertVecUnitStruct(_) => "insert_vec_unit_struct", - Reducer::NoOpSucceeds(_) => "no_op_succeeds", - Reducer::UpdatePkAddress(_) => "update_pk_address", - Reducer::UpdatePkBool(_) => "update_pk_bool", - Reducer::UpdatePkI128(_) => "update_pk_i128", - Reducer::UpdatePkI16(_) => "update_pk_i16", - Reducer::UpdatePkI256(_) => "update_pk_i256", - Reducer::UpdatePkI32(_) => "update_pk_i32", - Reducer::UpdatePkI64(_) => "update_pk_i64", - Reducer::UpdatePkI8(_) => "update_pk_i8", - Reducer::UpdatePkIdentity(_) => "update_pk_identity", - Reducer::UpdatePkString(_) => "update_pk_string", - Reducer::UpdatePkU128(_) => "update_pk_u128", - Reducer::UpdatePkU16(_) => "update_pk_u16", - Reducer::UpdatePkU256(_) => "update_pk_u256", - Reducer::UpdatePkU32(_) => "update_pk_u32", - Reducer::UpdatePkU64(_) => "update_pk_u64", - Reducer::UpdatePkU8(_) => "update_pk_u8", - Reducer::UpdateUniqueAddress(_) => "update_unique_address", - Reducer::UpdateUniqueBool(_) => "update_unique_bool", - Reducer::UpdateUniqueI128(_) => "update_unique_i128", - Reducer::UpdateUniqueI16(_) => "update_unique_i16", - Reducer::UpdateUniqueI256(_) => "update_unique_i256", - Reducer::UpdateUniqueI32(_) => "update_unique_i32", - Reducer::UpdateUniqueI64(_) => "update_unique_i64", - Reducer::UpdateUniqueI8(_) => "update_unique_i8", - Reducer::UpdateUniqueIdentity(_) => "update_unique_identity", - Reducer::UpdateUniqueString(_) => "update_unique_string", - Reducer::UpdateUniqueU128(_) => "update_unique_u128", - Reducer::UpdateUniqueU16(_) => "update_unique_u16", - Reducer::UpdateUniqueU256(_) => "update_unique_u256", - Reducer::UpdateUniqueU32(_) => "update_unique_u32", - Reducer::UpdateUniqueU64(_) => "update_unique_u64", - Reducer::UpdateUniqueU8(_) => "update_unique_u8", - } - } - fn reducer_args(&self) -> &dyn std::any::Any { - match self { - Reducer::DeletePkAddress(args) => args, - Reducer::DeletePkBool(args) => args, - Reducer::DeletePkI128(args) => args, - Reducer::DeletePkI16(args) => args, - Reducer::DeletePkI256(args) => args, - Reducer::DeletePkI32(args) => args, - Reducer::DeletePkI64(args) => args, - Reducer::DeletePkI8(args) => args, - Reducer::DeletePkIdentity(args) => args, - Reducer::DeletePkString(args) => args, - Reducer::DeletePkU128(args) => args, - Reducer::DeletePkU16(args) => args, - Reducer::DeletePkU256(args) => args, - Reducer::DeletePkU32(args) => args, - Reducer::DeletePkU64(args) => args, - Reducer::DeletePkU8(args) => args, - Reducer::DeleteUniqueAddress(args) => args, - Reducer::DeleteUniqueBool(args) => args, - Reducer::DeleteUniqueI128(args) => args, - Reducer::DeleteUniqueI16(args) => args, - Reducer::DeleteUniqueI256(args) => args, - Reducer::DeleteUniqueI32(args) => args, - Reducer::DeleteUniqueI64(args) => args, - Reducer::DeleteUniqueI8(args) => args, - Reducer::DeleteUniqueIdentity(args) => args, - Reducer::DeleteUniqueString(args) => args, - Reducer::DeleteUniqueU128(args) => args, - Reducer::DeleteUniqueU16(args) => args, - Reducer::DeleteUniqueU256(args) => args, - Reducer::DeleteUniqueU32(args) => args, - Reducer::DeleteUniqueU64(args) => args, - Reducer::DeleteUniqueU8(args) => args, - Reducer::InsertCallerOneAddress(args) => args, - Reducer::InsertCallerOneIdentity(args) => args, - Reducer::InsertCallerPkAddress(args) => args, - Reducer::InsertCallerPkIdentity(args) => args, - Reducer::InsertCallerUniqueAddress(args) => args, - Reducer::InsertCallerUniqueIdentity(args) => args, - Reducer::InsertCallerVecAddress(args) => args, - Reducer::InsertCallerVecIdentity(args) => args, - Reducer::InsertLargeTable(args) => args, - Reducer::InsertOneAddress(args) => args, - Reducer::InsertOneBool(args) => args, - Reducer::InsertOneByteStruct(args) => args, - Reducer::InsertOneEnumWithPayload(args) => args, - Reducer::InsertOneEveryPrimitiveStruct(args) => args, - Reducer::InsertOneEveryVecStruct(args) => args, - Reducer::InsertOneF32(args) => args, - Reducer::InsertOneF64(args) => args, - Reducer::InsertOneI128(args) => args, - Reducer::InsertOneI16(args) => args, - Reducer::InsertOneI256(args) => args, - Reducer::InsertOneI32(args) => args, - Reducer::InsertOneI64(args) => args, - Reducer::InsertOneI8(args) => args, - Reducer::InsertOneIdentity(args) => args, - Reducer::InsertOneSimpleEnum(args) => args, - Reducer::InsertOneString(args) => args, - Reducer::InsertOneU128(args) => args, - Reducer::InsertOneU16(args) => args, - Reducer::InsertOneU256(args) => args, - Reducer::InsertOneU32(args) => args, - Reducer::InsertOneU64(args) => args, - Reducer::InsertOneU8(args) => args, - Reducer::InsertOneUnitStruct(args) => args, - Reducer::InsertOptionEveryPrimitiveStruct(args) => args, - Reducer::InsertOptionI32(args) => args, - Reducer::InsertOptionIdentity(args) => args, - Reducer::InsertOptionSimpleEnum(args) => args, - Reducer::InsertOptionString(args) => args, - Reducer::InsertOptionVecOptionI32(args) => args, - Reducer::InsertPkAddress(args) => args, - Reducer::InsertPkBool(args) => args, - Reducer::InsertPkI128(args) => args, - Reducer::InsertPkI16(args) => args, - Reducer::InsertPkI256(args) => args, - Reducer::InsertPkI32(args) => args, - Reducer::InsertPkI64(args) => args, - Reducer::InsertPkI8(args) => args, - Reducer::InsertPkIdentity(args) => args, - Reducer::InsertPkString(args) => args, - Reducer::InsertPkU128(args) => args, - Reducer::InsertPkU16(args) => args, - Reducer::InsertPkU256(args) => args, - Reducer::InsertPkU32(args) => args, - Reducer::InsertPkU64(args) => args, - Reducer::InsertPkU8(args) => args, - Reducer::InsertPrimitivesAsStrings(args) => args, - Reducer::InsertTableHoldsTable(args) => args, - Reducer::InsertUniqueAddress(args) => args, - Reducer::InsertUniqueBool(args) => args, - Reducer::InsertUniqueI128(args) => args, - Reducer::InsertUniqueI16(args) => args, - Reducer::InsertUniqueI256(args) => args, - Reducer::InsertUniqueI32(args) => args, - Reducer::InsertUniqueI64(args) => args, - Reducer::InsertUniqueI8(args) => args, - Reducer::InsertUniqueIdentity(args) => args, - Reducer::InsertUniqueString(args) => args, - Reducer::InsertUniqueU128(args) => args, - Reducer::InsertUniqueU16(args) => args, - Reducer::InsertUniqueU256(args) => args, - Reducer::InsertUniqueU32(args) => args, - Reducer::InsertUniqueU64(args) => args, - Reducer::InsertUniqueU8(args) => args, - Reducer::InsertVecAddress(args) => args, - Reducer::InsertVecBool(args) => args, - Reducer::InsertVecByteStruct(args) => args, - Reducer::InsertVecEnumWithPayload(args) => args, - Reducer::InsertVecEveryPrimitiveStruct(args) => args, - Reducer::InsertVecEveryVecStruct(args) => args, - Reducer::InsertVecF32(args) => args, - Reducer::InsertVecF64(args) => args, - Reducer::InsertVecI128(args) => args, - Reducer::InsertVecI16(args) => args, - Reducer::InsertVecI256(args) => args, - Reducer::InsertVecI32(args) => args, - Reducer::InsertVecI64(args) => args, - Reducer::InsertVecI8(args) => args, - Reducer::InsertVecIdentity(args) => args, - Reducer::InsertVecSimpleEnum(args) => args, - Reducer::InsertVecString(args) => args, - Reducer::InsertVecU128(args) => args, - Reducer::InsertVecU16(args) => args, - Reducer::InsertVecU256(args) => args, - Reducer::InsertVecU32(args) => args, - Reducer::InsertVecU64(args) => args, - Reducer::InsertVecU8(args) => args, - Reducer::InsertVecUnitStruct(args) => args, - Reducer::NoOpSucceeds(args) => args, - Reducer::UpdatePkAddress(args) => args, - Reducer::UpdatePkBool(args) => args, - Reducer::UpdatePkI128(args) => args, - Reducer::UpdatePkI16(args) => args, - Reducer::UpdatePkI256(args) => args, - Reducer::UpdatePkI32(args) => args, - Reducer::UpdatePkI64(args) => args, - Reducer::UpdatePkI8(args) => args, - Reducer::UpdatePkIdentity(args) => args, - Reducer::UpdatePkString(args) => args, - Reducer::UpdatePkU128(args) => args, - Reducer::UpdatePkU16(args) => args, - Reducer::UpdatePkU256(args) => args, - Reducer::UpdatePkU32(args) => args, - Reducer::UpdatePkU64(args) => args, - Reducer::UpdatePkU8(args) => args, - Reducer::UpdateUniqueAddress(args) => args, - Reducer::UpdateUniqueBool(args) => args, - Reducer::UpdateUniqueI128(args) => args, - Reducer::UpdateUniqueI16(args) => args, - Reducer::UpdateUniqueI256(args) => args, - Reducer::UpdateUniqueI32(args) => args, - Reducer::UpdateUniqueI64(args) => args, - Reducer::UpdateUniqueI8(args) => args, - Reducer::UpdateUniqueIdentity(args) => args, - Reducer::UpdateUniqueString(args) => args, - Reducer::UpdateUniqueU128(args) => args, - Reducer::UpdateUniqueU16(args) => args, - Reducer::UpdateUniqueU256(args) => args, - Reducer::UpdateUniqueU32(args) => args, - Reducer::UpdateUniqueU64(args) => args, - Reducer::UpdateUniqueU8(args) => args, + Reducer::DeletePkAddress { .. } => "delete_pk_address", + Reducer::DeletePkBool { .. } => "delete_pk_bool", + Reducer::DeletePkI128 { .. } => "delete_pk_i128", + Reducer::DeletePkI16 { .. } => "delete_pk_i16", + Reducer::DeletePkI256 { .. } => "delete_pk_i256", + Reducer::DeletePkI32 { .. } => "delete_pk_i32", + Reducer::DeletePkI64 { .. } => "delete_pk_i64", + Reducer::DeletePkI8 { .. } => "delete_pk_i8", + Reducer::DeletePkIdentity { .. } => "delete_pk_identity", + Reducer::DeletePkString { .. } => "delete_pk_string", + Reducer::DeletePkU128 { .. } => "delete_pk_u128", + Reducer::DeletePkU16 { .. } => "delete_pk_u16", + Reducer::DeletePkU256 { .. } => "delete_pk_u256", + Reducer::DeletePkU32 { .. } => "delete_pk_u32", + Reducer::DeletePkU64 { .. } => "delete_pk_u64", + Reducer::DeletePkU8 { .. } => "delete_pk_u8", + Reducer::DeleteUniqueAddress { .. } => "delete_unique_address", + Reducer::DeleteUniqueBool { .. } => "delete_unique_bool", + Reducer::DeleteUniqueI128 { .. } => "delete_unique_i128", + Reducer::DeleteUniqueI16 { .. } => "delete_unique_i16", + Reducer::DeleteUniqueI256 { .. } => "delete_unique_i256", + Reducer::DeleteUniqueI32 { .. } => "delete_unique_i32", + Reducer::DeleteUniqueI64 { .. } => "delete_unique_i64", + Reducer::DeleteUniqueI8 { .. } => "delete_unique_i8", + Reducer::DeleteUniqueIdentity { .. } => "delete_unique_identity", + Reducer::DeleteUniqueString { .. } => "delete_unique_string", + Reducer::DeleteUniqueU128 { .. } => "delete_unique_u128", + Reducer::DeleteUniqueU16 { .. } => "delete_unique_u16", + Reducer::DeleteUniqueU256 { .. } => "delete_unique_u256", + Reducer::DeleteUniqueU32 { .. } => "delete_unique_u32", + Reducer::DeleteUniqueU64 { .. } => "delete_unique_u64", + Reducer::DeleteUniqueU8 { .. } => "delete_unique_u8", + Reducer::InsertCallerOneAddress => "insert_caller_one_address", + Reducer::InsertCallerOneIdentity => "insert_caller_one_identity", + Reducer::InsertCallerPkAddress { .. } => "insert_caller_pk_address", + Reducer::InsertCallerPkIdentity { .. } => "insert_caller_pk_identity", + Reducer::InsertCallerUniqueAddress { .. } => "insert_caller_unique_address", + Reducer::InsertCallerUniqueIdentity { .. } => "insert_caller_unique_identity", + Reducer::InsertCallerVecAddress => "insert_caller_vec_address", + Reducer::InsertCallerVecIdentity => "insert_caller_vec_identity", + Reducer::InsertLargeTable { .. } => "insert_large_table", + Reducer::InsertOneAddress { .. } => "insert_one_address", + Reducer::InsertOneBool { .. } => "insert_one_bool", + Reducer::InsertOneByteStruct { .. } => "insert_one_byte_struct", + Reducer::InsertOneEnumWithPayload { .. } => "insert_one_enum_with_payload", + Reducer::InsertOneEveryPrimitiveStruct { .. } => "insert_one_every_primitive_struct", + Reducer::InsertOneEveryVecStruct { .. } => "insert_one_every_vec_struct", + Reducer::InsertOneF32 { .. } => "insert_one_f32", + Reducer::InsertOneF64 { .. } => "insert_one_f64", + Reducer::InsertOneI128 { .. } => "insert_one_i128", + Reducer::InsertOneI16 { .. } => "insert_one_i16", + Reducer::InsertOneI256 { .. } => "insert_one_i256", + Reducer::InsertOneI32 { .. } => "insert_one_i32", + Reducer::InsertOneI64 { .. } => "insert_one_i64", + Reducer::InsertOneI8 { .. } => "insert_one_i8", + Reducer::InsertOneIdentity { .. } => "insert_one_identity", + Reducer::InsertOneSimpleEnum { .. } => "insert_one_simple_enum", + Reducer::InsertOneString { .. } => "insert_one_string", + Reducer::InsertOneU128 { .. } => "insert_one_u128", + Reducer::InsertOneU16 { .. } => "insert_one_u16", + Reducer::InsertOneU256 { .. } => "insert_one_u256", + Reducer::InsertOneU32 { .. } => "insert_one_u32", + Reducer::InsertOneU64 { .. } => "insert_one_u64", + Reducer::InsertOneU8 { .. } => "insert_one_u8", + Reducer::InsertOneUnitStruct { .. } => "insert_one_unit_struct", + Reducer::InsertOptionEveryPrimitiveStruct { .. } => "insert_option_every_primitive_struct", + Reducer::InsertOptionI32 { .. } => "insert_option_i32", + Reducer::InsertOptionIdentity { .. } => "insert_option_identity", + Reducer::InsertOptionSimpleEnum { .. } => "insert_option_simple_enum", + Reducer::InsertOptionString { .. } => "insert_option_string", + Reducer::InsertOptionVecOptionI32 { .. } => "insert_option_vec_option_i32", + Reducer::InsertPkAddress { .. } => "insert_pk_address", + Reducer::InsertPkBool { .. } => "insert_pk_bool", + Reducer::InsertPkI128 { .. } => "insert_pk_i128", + Reducer::InsertPkI16 { .. } => "insert_pk_i16", + Reducer::InsertPkI256 { .. } => "insert_pk_i256", + Reducer::InsertPkI32 { .. } => "insert_pk_i32", + Reducer::InsertPkI64 { .. } => "insert_pk_i64", + Reducer::InsertPkI8 { .. } => "insert_pk_i8", + Reducer::InsertPkIdentity { .. } => "insert_pk_identity", + Reducer::InsertPkString { .. } => "insert_pk_string", + Reducer::InsertPkU128 { .. } => "insert_pk_u128", + Reducer::InsertPkU16 { .. } => "insert_pk_u16", + Reducer::InsertPkU256 { .. } => "insert_pk_u256", + Reducer::InsertPkU32 { .. } => "insert_pk_u32", + Reducer::InsertPkU64 { .. } => "insert_pk_u64", + Reducer::InsertPkU8 { .. } => "insert_pk_u8", + Reducer::InsertPrimitivesAsStrings { .. } => "insert_primitives_as_strings", + Reducer::InsertTableHoldsTable { .. } => "insert_table_holds_table", + Reducer::InsertUniqueAddress { .. } => "insert_unique_address", + Reducer::InsertUniqueBool { .. } => "insert_unique_bool", + Reducer::InsertUniqueI128 { .. } => "insert_unique_i128", + Reducer::InsertUniqueI16 { .. } => "insert_unique_i16", + Reducer::InsertUniqueI256 { .. } => "insert_unique_i256", + Reducer::InsertUniqueI32 { .. } => "insert_unique_i32", + Reducer::InsertUniqueI64 { .. } => "insert_unique_i64", + Reducer::InsertUniqueI8 { .. } => "insert_unique_i8", + Reducer::InsertUniqueIdentity { .. } => "insert_unique_identity", + Reducer::InsertUniqueString { .. } => "insert_unique_string", + Reducer::InsertUniqueU128 { .. } => "insert_unique_u128", + Reducer::InsertUniqueU16 { .. } => "insert_unique_u16", + Reducer::InsertUniqueU256 { .. } => "insert_unique_u256", + Reducer::InsertUniqueU32 { .. } => "insert_unique_u32", + Reducer::InsertUniqueU64 { .. } => "insert_unique_u64", + Reducer::InsertUniqueU8 { .. } => "insert_unique_u8", + Reducer::InsertVecAddress { .. } => "insert_vec_address", + Reducer::InsertVecBool { .. } => "insert_vec_bool", + Reducer::InsertVecByteStruct { .. } => "insert_vec_byte_struct", + Reducer::InsertVecEnumWithPayload { .. } => "insert_vec_enum_with_payload", + Reducer::InsertVecEveryPrimitiveStruct { .. } => "insert_vec_every_primitive_struct", + Reducer::InsertVecEveryVecStruct { .. } => "insert_vec_every_vec_struct", + Reducer::InsertVecF32 { .. } => "insert_vec_f32", + Reducer::InsertVecF64 { .. } => "insert_vec_f64", + Reducer::InsertVecI128 { .. } => "insert_vec_i128", + Reducer::InsertVecI16 { .. } => "insert_vec_i16", + Reducer::InsertVecI256 { .. } => "insert_vec_i256", + Reducer::InsertVecI32 { .. } => "insert_vec_i32", + Reducer::InsertVecI64 { .. } => "insert_vec_i64", + Reducer::InsertVecI8 { .. } => "insert_vec_i8", + Reducer::InsertVecIdentity { .. } => "insert_vec_identity", + Reducer::InsertVecSimpleEnum { .. } => "insert_vec_simple_enum", + Reducer::InsertVecString { .. } => "insert_vec_string", + Reducer::InsertVecU128 { .. } => "insert_vec_u128", + Reducer::InsertVecU16 { .. } => "insert_vec_u16", + Reducer::InsertVecU256 { .. } => "insert_vec_u256", + Reducer::InsertVecU32 { .. } => "insert_vec_u32", + Reducer::InsertVecU64 { .. } => "insert_vec_u64", + Reducer::InsertVecU8 { .. } => "insert_vec_u8", + Reducer::InsertVecUnitStruct { .. } => "insert_vec_unit_struct", + Reducer::NoOpSucceeds => "no_op_succeeds", + Reducer::SendScheduledMessage { .. } => "send_scheduled_message", + Reducer::UpdatePkAddress { .. } => "update_pk_address", + Reducer::UpdatePkBool { .. } => "update_pk_bool", + Reducer::UpdatePkI128 { .. } => "update_pk_i128", + Reducer::UpdatePkI16 { .. } => "update_pk_i16", + Reducer::UpdatePkI256 { .. } => "update_pk_i256", + Reducer::UpdatePkI32 { .. } => "update_pk_i32", + Reducer::UpdatePkI64 { .. } => "update_pk_i64", + Reducer::UpdatePkI8 { .. } => "update_pk_i8", + Reducer::UpdatePkIdentity { .. } => "update_pk_identity", + Reducer::UpdatePkString { .. } => "update_pk_string", + Reducer::UpdatePkU128 { .. } => "update_pk_u128", + Reducer::UpdatePkU16 { .. } => "update_pk_u16", + Reducer::UpdatePkU256 { .. } => "update_pk_u256", + Reducer::UpdatePkU32 { .. } => "update_pk_u32", + Reducer::UpdatePkU64 { .. } => "update_pk_u64", + Reducer::UpdatePkU8 { .. } => "update_pk_u8", + Reducer::UpdateUniqueAddress { .. } => "update_unique_address", + Reducer::UpdateUniqueBool { .. } => "update_unique_bool", + Reducer::UpdateUniqueI128 { .. } => "update_unique_i128", + Reducer::UpdateUniqueI16 { .. } => "update_unique_i16", + Reducer::UpdateUniqueI256 { .. } => "update_unique_i256", + Reducer::UpdateUniqueI32 { .. } => "update_unique_i32", + Reducer::UpdateUniqueI64 { .. } => "update_unique_i64", + Reducer::UpdateUniqueI8 { .. } => "update_unique_i8", + Reducer::UpdateUniqueIdentity { .. } => "update_unique_identity", + Reducer::UpdateUniqueString { .. } => "update_unique_string", + Reducer::UpdateUniqueU128 { .. } => "update_unique_u128", + Reducer::UpdateUniqueU16 { .. } => "update_unique_u16", + Reducer::UpdateUniqueU256 { .. } => "update_unique_u256", + Reducer::UpdateUniqueU32 { .. } => "update_unique_u32", + Reducer::UpdateUniqueU64 { .. } => "update_unique_u64", + Reducer::UpdateUniqueU8 { .. } => "update_unique_u8", } } } @@ -1213,618 +1586,914 @@ impl TryFrom<__ws::ReducerCallInfo<__ws::BsatnFormat>> for Reducer { type Error = __anyhow::Error; fn try_from(value: __ws::ReducerCallInfo<__ws::BsatnFormat>) -> __anyhow::Result { match &value.reducer_name[..] { - "delete_pk_address" => Ok(Reducer::DeletePkAddress(__sdk::spacetime_module::parse_reducer_args( - "delete_pk_address", - &value.args, - )?)), - "delete_pk_bool" => Ok(Reducer::DeletePkBool(__sdk::spacetime_module::parse_reducer_args( + "delete_pk_address" => Ok( + __sdk::parse_reducer_args::( + "delete_pk_address", + &value.args, + )? + .into(), + ), + "delete_pk_bool" => Ok(__sdk::parse_reducer_args::( "delete_pk_bool", &value.args, - )?)), - "delete_pk_i128" => Ok(Reducer::DeletePkI128(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "delete_pk_i128" => Ok(__sdk::parse_reducer_args::( "delete_pk_i128", &value.args, - )?)), - "delete_pk_i16" => Ok(Reducer::DeletePkI16(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "delete_pk_i16" => Ok(__sdk::parse_reducer_args::( "delete_pk_i16", &value.args, - )?)), - "delete_pk_i256" => Ok(Reducer::DeletePkI256(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "delete_pk_i256" => Ok(__sdk::parse_reducer_args::( "delete_pk_i256", &value.args, - )?)), - "delete_pk_i32" => Ok(Reducer::DeletePkI32(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "delete_pk_i32" => Ok(__sdk::parse_reducer_args::( "delete_pk_i32", &value.args, - )?)), - "delete_pk_i64" => Ok(Reducer::DeletePkI64(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "delete_pk_i64" => Ok(__sdk::parse_reducer_args::( "delete_pk_i64", &value.args, - )?)), - "delete_pk_i8" => Ok(Reducer::DeletePkI8(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "delete_pk_i8" => Ok(__sdk::parse_reducer_args::( "delete_pk_i8", &value.args, - )?)), - "delete_pk_identity" => Ok(Reducer::DeletePkIdentity(__sdk::spacetime_module::parse_reducer_args( - "delete_pk_identity", - &value.args, - )?)), - "delete_pk_string" => Ok(Reducer::DeletePkString(__sdk::spacetime_module::parse_reducer_args( - "delete_pk_string", - &value.args, - )?)), - "delete_pk_u128" => Ok(Reducer::DeletePkU128(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "delete_pk_identity" => Ok( + __sdk::parse_reducer_args::( + "delete_pk_identity", + &value.args, + )? + .into(), + ), + "delete_pk_string" => Ok( + __sdk::parse_reducer_args::( + "delete_pk_string", + &value.args, + )? + .into(), + ), + "delete_pk_u128" => Ok(__sdk::parse_reducer_args::( "delete_pk_u128", &value.args, - )?)), - "delete_pk_u16" => Ok(Reducer::DeletePkU16(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "delete_pk_u16" => Ok(__sdk::parse_reducer_args::( "delete_pk_u16", &value.args, - )?)), - "delete_pk_u256" => Ok(Reducer::DeletePkU256(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "delete_pk_u256" => Ok(__sdk::parse_reducer_args::( "delete_pk_u256", &value.args, - )?)), - "delete_pk_u32" => Ok(Reducer::DeletePkU32(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "delete_pk_u32" => Ok(__sdk::parse_reducer_args::( "delete_pk_u32", &value.args, - )?)), - "delete_pk_u64" => Ok(Reducer::DeletePkU64(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "delete_pk_u64" => Ok(__sdk::parse_reducer_args::( "delete_pk_u64", &value.args, - )?)), - "delete_pk_u8" => Ok(Reducer::DeletePkU8(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "delete_pk_u8" => Ok(__sdk::parse_reducer_args::( "delete_pk_u8", &value.args, - )?)), - "delete_unique_address" => Ok(Reducer::DeleteUniqueAddress( - __sdk::spacetime_module::parse_reducer_args("delete_unique_address", &value.args)?, - )), - "delete_unique_bool" => Ok(Reducer::DeleteUniqueBool(__sdk::spacetime_module::parse_reducer_args( - "delete_unique_bool", - &value.args, - )?)), - "delete_unique_i128" => Ok(Reducer::DeleteUniqueI128(__sdk::spacetime_module::parse_reducer_args( - "delete_unique_i128", - &value.args, - )?)), - "delete_unique_i16" => Ok(Reducer::DeleteUniqueI16(__sdk::spacetime_module::parse_reducer_args( - "delete_unique_i16", - &value.args, - )?)), - "delete_unique_i256" => Ok(Reducer::DeleteUniqueI256(__sdk::spacetime_module::parse_reducer_args( - "delete_unique_i256", - &value.args, - )?)), - "delete_unique_i32" => Ok(Reducer::DeleteUniqueI32(__sdk::spacetime_module::parse_reducer_args( - "delete_unique_i32", - &value.args, - )?)), - "delete_unique_i64" => Ok(Reducer::DeleteUniqueI64(__sdk::spacetime_module::parse_reducer_args( - "delete_unique_i64", - &value.args, - )?)), - "delete_unique_i8" => Ok(Reducer::DeleteUniqueI8(__sdk::spacetime_module::parse_reducer_args( - "delete_unique_i8", - &value.args, - )?)), - "delete_unique_identity" => Ok(Reducer::DeleteUniqueIdentity( - __sdk::spacetime_module::parse_reducer_args("delete_unique_identity", &value.args)?, - )), - "delete_unique_string" => Ok(Reducer::DeleteUniqueString( - __sdk::spacetime_module::parse_reducer_args("delete_unique_string", &value.args)?, - )), - "delete_unique_u128" => Ok(Reducer::DeleteUniqueU128(__sdk::spacetime_module::parse_reducer_args( - "delete_unique_u128", - &value.args, - )?)), - "delete_unique_u16" => Ok(Reducer::DeleteUniqueU16(__sdk::spacetime_module::parse_reducer_args( - "delete_unique_u16", - &value.args, - )?)), - "delete_unique_u256" => Ok(Reducer::DeleteUniqueU256(__sdk::spacetime_module::parse_reducer_args( - "delete_unique_u256", - &value.args, - )?)), - "delete_unique_u32" => Ok(Reducer::DeleteUniqueU32(__sdk::spacetime_module::parse_reducer_args( - "delete_unique_u32", - &value.args, - )?)), - "delete_unique_u64" => Ok(Reducer::DeleteUniqueU64(__sdk::spacetime_module::parse_reducer_args( - "delete_unique_u64", - &value.args, - )?)), - "delete_unique_u8" => Ok(Reducer::DeleteUniqueU8(__sdk::spacetime_module::parse_reducer_args( - "delete_unique_u8", - &value.args, - )?)), - "insert_caller_one_address" => Ok(Reducer::InsertCallerOneAddress( - __sdk::spacetime_module::parse_reducer_args("insert_caller_one_address", &value.args)?, - )), - "insert_caller_one_identity" => Ok(Reducer::InsertCallerOneIdentity( - __sdk::spacetime_module::parse_reducer_args("insert_caller_one_identity", &value.args)?, - )), - "insert_caller_pk_address" => Ok(Reducer::InsertCallerPkAddress( - __sdk::spacetime_module::parse_reducer_args("insert_caller_pk_address", &value.args)?, - )), - "insert_caller_pk_identity" => Ok(Reducer::InsertCallerPkIdentity( - __sdk::spacetime_module::parse_reducer_args("insert_caller_pk_identity", &value.args)?, - )), - "insert_caller_unique_address" => Ok(Reducer::InsertCallerUniqueAddress( - __sdk::spacetime_module::parse_reducer_args("insert_caller_unique_address", &value.args)?, - )), - "insert_caller_unique_identity" => Ok(Reducer::InsertCallerUniqueIdentity( - __sdk::spacetime_module::parse_reducer_args("insert_caller_unique_identity", &value.args)?, - )), - "insert_caller_vec_address" => Ok(Reducer::InsertCallerVecAddress( - __sdk::spacetime_module::parse_reducer_args("insert_caller_vec_address", &value.args)?, - )), - "insert_caller_vec_identity" => Ok(Reducer::InsertCallerVecIdentity( - __sdk::spacetime_module::parse_reducer_args("insert_caller_vec_identity", &value.args)?, - )), - "insert_large_table" => Ok(Reducer::InsertLargeTable(__sdk::spacetime_module::parse_reducer_args( - "insert_large_table", - &value.args, - )?)), - "insert_one_address" => Ok(Reducer::InsertOneAddress(__sdk::spacetime_module::parse_reducer_args( - "insert_one_address", - &value.args, - )?)), - "insert_one_bool" => Ok(Reducer::InsertOneBool(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "delete_unique_address" => Ok(__sdk::parse_reducer_args::< + delete_unique_address_reducer::DeleteUniqueAddressArgs, + >("delete_unique_address", &value.args)? + .into()), + "delete_unique_bool" => Ok( + __sdk::parse_reducer_args::( + "delete_unique_bool", + &value.args, + )? + .into(), + ), + "delete_unique_i128" => Ok( + __sdk::parse_reducer_args::( + "delete_unique_i128", + &value.args, + )? + .into(), + ), + "delete_unique_i16" => Ok( + __sdk::parse_reducer_args::( + "delete_unique_i16", + &value.args, + )? + .into(), + ), + "delete_unique_i256" => Ok( + __sdk::parse_reducer_args::( + "delete_unique_i256", + &value.args, + )? + .into(), + ), + "delete_unique_i32" => Ok( + __sdk::parse_reducer_args::( + "delete_unique_i32", + &value.args, + )? + .into(), + ), + "delete_unique_i64" => Ok( + __sdk::parse_reducer_args::( + "delete_unique_i64", + &value.args, + )? + .into(), + ), + "delete_unique_i8" => Ok( + __sdk::parse_reducer_args::( + "delete_unique_i8", + &value.args, + )? + .into(), + ), + "delete_unique_identity" => Ok(__sdk::parse_reducer_args::< + delete_unique_identity_reducer::DeleteUniqueIdentityArgs, + >("delete_unique_identity", &value.args)? + .into()), + "delete_unique_string" => Ok(__sdk::parse_reducer_args::< + delete_unique_string_reducer::DeleteUniqueStringArgs, + >("delete_unique_string", &value.args)? + .into()), + "delete_unique_u128" => Ok( + __sdk::parse_reducer_args::( + "delete_unique_u128", + &value.args, + )? + .into(), + ), + "delete_unique_u16" => Ok( + __sdk::parse_reducer_args::( + "delete_unique_u16", + &value.args, + )? + .into(), + ), + "delete_unique_u256" => Ok( + __sdk::parse_reducer_args::( + "delete_unique_u256", + &value.args, + )? + .into(), + ), + "delete_unique_u32" => Ok( + __sdk::parse_reducer_args::( + "delete_unique_u32", + &value.args, + )? + .into(), + ), + "delete_unique_u64" => Ok( + __sdk::parse_reducer_args::( + "delete_unique_u64", + &value.args, + )? + .into(), + ), + "delete_unique_u8" => Ok( + __sdk::parse_reducer_args::( + "delete_unique_u8", + &value.args, + )? + .into(), + ), + "insert_caller_one_address" => Ok(__sdk::parse_reducer_args::< + insert_caller_one_address_reducer::InsertCallerOneAddressArgs, + >("insert_caller_one_address", &value.args)? + .into()), + "insert_caller_one_identity" => Ok(__sdk::parse_reducer_args::< + insert_caller_one_identity_reducer::InsertCallerOneIdentityArgs, + >("insert_caller_one_identity", &value.args)? + .into()), + "insert_caller_pk_address" => Ok(__sdk::parse_reducer_args::< + insert_caller_pk_address_reducer::InsertCallerPkAddressArgs, + >("insert_caller_pk_address", &value.args)? + .into()), + "insert_caller_pk_identity" => Ok(__sdk::parse_reducer_args::< + insert_caller_pk_identity_reducer::InsertCallerPkIdentityArgs, + >("insert_caller_pk_identity", &value.args)? + .into()), + "insert_caller_unique_address" => Ok(__sdk::parse_reducer_args::< + insert_caller_unique_address_reducer::InsertCallerUniqueAddressArgs, + >("insert_caller_unique_address", &value.args)? + .into()), + "insert_caller_unique_identity" => Ok(__sdk::parse_reducer_args::< + insert_caller_unique_identity_reducer::InsertCallerUniqueIdentityArgs, + >("insert_caller_unique_identity", &value.args)? + .into()), + "insert_caller_vec_address" => Ok(__sdk::parse_reducer_args::< + insert_caller_vec_address_reducer::InsertCallerVecAddressArgs, + >("insert_caller_vec_address", &value.args)? + .into()), + "insert_caller_vec_identity" => Ok(__sdk::parse_reducer_args::< + insert_caller_vec_identity_reducer::InsertCallerVecIdentityArgs, + >("insert_caller_vec_identity", &value.args)? + .into()), + "insert_large_table" => Ok( + __sdk::parse_reducer_args::( + "insert_large_table", + &value.args, + )? + .into(), + ), + "insert_one_address" => Ok( + __sdk::parse_reducer_args::( + "insert_one_address", + &value.args, + )? + .into(), + ), + "insert_one_bool" => Ok(__sdk::parse_reducer_args::( "insert_one_bool", &value.args, - )?)), - "insert_one_byte_struct" => Ok(Reducer::InsertOneByteStruct( - __sdk::spacetime_module::parse_reducer_args("insert_one_byte_struct", &value.args)?, - )), - "insert_one_enum_with_payload" => Ok(Reducer::InsertOneEnumWithPayload( - __sdk::spacetime_module::parse_reducer_args("insert_one_enum_with_payload", &value.args)?, - )), - "insert_one_every_primitive_struct" => Ok(Reducer::InsertOneEveryPrimitiveStruct( - __sdk::spacetime_module::parse_reducer_args("insert_one_every_primitive_struct", &value.args)?, - )), - "insert_one_every_vec_struct" => Ok(Reducer::InsertOneEveryVecStruct( - __sdk::spacetime_module::parse_reducer_args("insert_one_every_vec_struct", &value.args)?, - )), - "insert_one_f32" => Ok(Reducer::InsertOneF32(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_one_byte_struct" => Ok(__sdk::parse_reducer_args::< + insert_one_byte_struct_reducer::InsertOneByteStructArgs, + >("insert_one_byte_struct", &value.args)? + .into()), + "insert_one_enum_with_payload" => Ok(__sdk::parse_reducer_args::< + insert_one_enum_with_payload_reducer::InsertOneEnumWithPayloadArgs, + >("insert_one_enum_with_payload", &value.args)? + .into()), + "insert_one_every_primitive_struct" => Ok(__sdk::parse_reducer_args::< + insert_one_every_primitive_struct_reducer::InsertOneEveryPrimitiveStructArgs, + >("insert_one_every_primitive_struct", &value.args)? + .into()), + "insert_one_every_vec_struct" => Ok(__sdk::parse_reducer_args::< + insert_one_every_vec_struct_reducer::InsertOneEveryVecStructArgs, + >("insert_one_every_vec_struct", &value.args)? + .into()), + "insert_one_f32" => Ok(__sdk::parse_reducer_args::( "insert_one_f32", &value.args, - )?)), - "insert_one_f64" => Ok(Reducer::InsertOneF64(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_one_f64" => Ok(__sdk::parse_reducer_args::( "insert_one_f64", &value.args, - )?)), - "insert_one_i128" => Ok(Reducer::InsertOneI128(__sdk::spacetime_module::parse_reducer_args( - "insert_one_i128", - &value.args, - )?)), - "insert_one_i16" => Ok(Reducer::InsertOneI16(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_one_i128" => Ok( + __sdk::parse_reducer_args::( + "insert_one_i128", + &value.args, + )? + .into(), + ), + "insert_one_i16" => Ok(__sdk::parse_reducer_args::( "insert_one_i16", &value.args, - )?)), - "insert_one_i256" => Ok(Reducer::InsertOneI256(__sdk::spacetime_module::parse_reducer_args( - "insert_one_i256", - &value.args, - )?)), - "insert_one_i32" => Ok(Reducer::InsertOneI32(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_one_i256" => Ok( + __sdk::parse_reducer_args::( + "insert_one_i256", + &value.args, + )? + .into(), + ), + "insert_one_i32" => Ok(__sdk::parse_reducer_args::( "insert_one_i32", &value.args, - )?)), - "insert_one_i64" => Ok(Reducer::InsertOneI64(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_one_i64" => Ok(__sdk::parse_reducer_args::( "insert_one_i64", &value.args, - )?)), - "insert_one_i8" => Ok(Reducer::InsertOneI8(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_one_i8" => Ok(__sdk::parse_reducer_args::( "insert_one_i8", &value.args, - )?)), - "insert_one_identity" => Ok(Reducer::InsertOneIdentity(__sdk::spacetime_module::parse_reducer_args( - "insert_one_identity", - &value.args, - )?)), - "insert_one_simple_enum" => Ok(Reducer::InsertOneSimpleEnum( - __sdk::spacetime_module::parse_reducer_args("insert_one_simple_enum", &value.args)?, - )), - "insert_one_string" => Ok(Reducer::InsertOneString(__sdk::spacetime_module::parse_reducer_args( - "insert_one_string", - &value.args, - )?)), - "insert_one_u128" => Ok(Reducer::InsertOneU128(__sdk::spacetime_module::parse_reducer_args( - "insert_one_u128", - &value.args, - )?)), - "insert_one_u16" => Ok(Reducer::InsertOneU16(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_one_identity" => Ok( + __sdk::parse_reducer_args::( + "insert_one_identity", + &value.args, + )? + .into(), + ), + "insert_one_simple_enum" => Ok(__sdk::parse_reducer_args::< + insert_one_simple_enum_reducer::InsertOneSimpleEnumArgs, + >("insert_one_simple_enum", &value.args)? + .into()), + "insert_one_string" => Ok( + __sdk::parse_reducer_args::( + "insert_one_string", + &value.args, + )? + .into(), + ), + "insert_one_u128" => Ok( + __sdk::parse_reducer_args::( + "insert_one_u128", + &value.args, + )? + .into(), + ), + "insert_one_u16" => Ok(__sdk::parse_reducer_args::( "insert_one_u16", &value.args, - )?)), - "insert_one_u256" => Ok(Reducer::InsertOneU256(__sdk::spacetime_module::parse_reducer_args( - "insert_one_u256", - &value.args, - )?)), - "insert_one_u32" => Ok(Reducer::InsertOneU32(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_one_u256" => Ok( + __sdk::parse_reducer_args::( + "insert_one_u256", + &value.args, + )? + .into(), + ), + "insert_one_u32" => Ok(__sdk::parse_reducer_args::( "insert_one_u32", &value.args, - )?)), - "insert_one_u64" => Ok(Reducer::InsertOneU64(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_one_u64" => Ok(__sdk::parse_reducer_args::( "insert_one_u64", &value.args, - )?)), - "insert_one_u8" => Ok(Reducer::InsertOneU8(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_one_u8" => Ok(__sdk::parse_reducer_args::( "insert_one_u8", &value.args, - )?)), - "insert_one_unit_struct" => Ok(Reducer::InsertOneUnitStruct( - __sdk::spacetime_module::parse_reducer_args("insert_one_unit_struct", &value.args)?, - )), - "insert_option_every_primitive_struct" => Ok(Reducer::InsertOptionEveryPrimitiveStruct( - __sdk::spacetime_module::parse_reducer_args("insert_option_every_primitive_struct", &value.args)?, - )), - "insert_option_i32" => Ok(Reducer::InsertOptionI32(__sdk::spacetime_module::parse_reducer_args( - "insert_option_i32", - &value.args, - )?)), - "insert_option_identity" => Ok(Reducer::InsertOptionIdentity( - __sdk::spacetime_module::parse_reducer_args("insert_option_identity", &value.args)?, - )), - "insert_option_simple_enum" => Ok(Reducer::InsertOptionSimpleEnum( - __sdk::spacetime_module::parse_reducer_args("insert_option_simple_enum", &value.args)?, - )), - "insert_option_string" => Ok(Reducer::InsertOptionString( - __sdk::spacetime_module::parse_reducer_args("insert_option_string", &value.args)?, - )), - "insert_option_vec_option_i32" => Ok(Reducer::InsertOptionVecOptionI32( - __sdk::spacetime_module::parse_reducer_args("insert_option_vec_option_i32", &value.args)?, - )), - "insert_pk_address" => Ok(Reducer::InsertPkAddress(__sdk::spacetime_module::parse_reducer_args( - "insert_pk_address", - &value.args, - )?)), - "insert_pk_bool" => Ok(Reducer::InsertPkBool(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_one_unit_struct" => Ok(__sdk::parse_reducer_args::< + insert_one_unit_struct_reducer::InsertOneUnitStructArgs, + >("insert_one_unit_struct", &value.args)? + .into()), + "insert_option_every_primitive_struct" => { + Ok(__sdk::parse_reducer_args::< + insert_option_every_primitive_struct_reducer::InsertOptionEveryPrimitiveStructArgs, + >("insert_option_every_primitive_struct", &value.args)? + .into()) + } + "insert_option_i32" => Ok( + __sdk::parse_reducer_args::( + "insert_option_i32", + &value.args, + )? + .into(), + ), + "insert_option_identity" => Ok(__sdk::parse_reducer_args::< + insert_option_identity_reducer::InsertOptionIdentityArgs, + >("insert_option_identity", &value.args)? + .into()), + "insert_option_simple_enum" => Ok(__sdk::parse_reducer_args::< + insert_option_simple_enum_reducer::InsertOptionSimpleEnumArgs, + >("insert_option_simple_enum", &value.args)? + .into()), + "insert_option_string" => Ok(__sdk::parse_reducer_args::< + insert_option_string_reducer::InsertOptionStringArgs, + >("insert_option_string", &value.args)? + .into()), + "insert_option_vec_option_i32" => Ok(__sdk::parse_reducer_args::< + insert_option_vec_option_i_32_reducer::InsertOptionVecOptionI32Args, + >("insert_option_vec_option_i32", &value.args)? + .into()), + "insert_pk_address" => Ok( + __sdk::parse_reducer_args::( + "insert_pk_address", + &value.args, + )? + .into(), + ), + "insert_pk_bool" => Ok(__sdk::parse_reducer_args::( "insert_pk_bool", &value.args, - )?)), - "insert_pk_i128" => Ok(Reducer::InsertPkI128(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_pk_i128" => Ok(__sdk::parse_reducer_args::( "insert_pk_i128", &value.args, - )?)), - "insert_pk_i16" => Ok(Reducer::InsertPkI16(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_pk_i16" => Ok(__sdk::parse_reducer_args::( "insert_pk_i16", &value.args, - )?)), - "insert_pk_i256" => Ok(Reducer::InsertPkI256(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_pk_i256" => Ok(__sdk::parse_reducer_args::( "insert_pk_i256", &value.args, - )?)), - "insert_pk_i32" => Ok(Reducer::InsertPkI32(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_pk_i32" => Ok(__sdk::parse_reducer_args::( "insert_pk_i32", &value.args, - )?)), - "insert_pk_i64" => Ok(Reducer::InsertPkI64(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_pk_i64" => Ok(__sdk::parse_reducer_args::( "insert_pk_i64", &value.args, - )?)), - "insert_pk_i8" => Ok(Reducer::InsertPkI8(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_pk_i8" => Ok(__sdk::parse_reducer_args::( "insert_pk_i8", &value.args, - )?)), - "insert_pk_identity" => Ok(Reducer::InsertPkIdentity(__sdk::spacetime_module::parse_reducer_args( - "insert_pk_identity", - &value.args, - )?)), - "insert_pk_string" => Ok(Reducer::InsertPkString(__sdk::spacetime_module::parse_reducer_args( - "insert_pk_string", - &value.args, - )?)), - "insert_pk_u128" => Ok(Reducer::InsertPkU128(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_pk_identity" => Ok( + __sdk::parse_reducer_args::( + "insert_pk_identity", + &value.args, + )? + .into(), + ), + "insert_pk_string" => Ok( + __sdk::parse_reducer_args::( + "insert_pk_string", + &value.args, + )? + .into(), + ), + "insert_pk_u128" => Ok(__sdk::parse_reducer_args::( "insert_pk_u128", &value.args, - )?)), - "insert_pk_u16" => Ok(Reducer::InsertPkU16(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_pk_u16" => Ok(__sdk::parse_reducer_args::( "insert_pk_u16", &value.args, - )?)), - "insert_pk_u256" => Ok(Reducer::InsertPkU256(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_pk_u256" => Ok(__sdk::parse_reducer_args::( "insert_pk_u256", &value.args, - )?)), - "insert_pk_u32" => Ok(Reducer::InsertPkU32(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_pk_u32" => Ok(__sdk::parse_reducer_args::( "insert_pk_u32", &value.args, - )?)), - "insert_pk_u64" => Ok(Reducer::InsertPkU64(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_pk_u64" => Ok(__sdk::parse_reducer_args::( "insert_pk_u64", &value.args, - )?)), - "insert_pk_u8" => Ok(Reducer::InsertPkU8(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_pk_u8" => Ok(__sdk::parse_reducer_args::( "insert_pk_u8", &value.args, - )?)), - "insert_primitives_as_strings" => Ok(Reducer::InsertPrimitivesAsStrings( - __sdk::spacetime_module::parse_reducer_args("insert_primitives_as_strings", &value.args)?, - )), - "insert_table_holds_table" => Ok(Reducer::InsertTableHoldsTable( - __sdk::spacetime_module::parse_reducer_args("insert_table_holds_table", &value.args)?, - )), - "insert_unique_address" => Ok(Reducer::InsertUniqueAddress( - __sdk::spacetime_module::parse_reducer_args("insert_unique_address", &value.args)?, - )), - "insert_unique_bool" => Ok(Reducer::InsertUniqueBool(__sdk::spacetime_module::parse_reducer_args( - "insert_unique_bool", - &value.args, - )?)), - "insert_unique_i128" => Ok(Reducer::InsertUniqueI128(__sdk::spacetime_module::parse_reducer_args( - "insert_unique_i128", - &value.args, - )?)), - "insert_unique_i16" => Ok(Reducer::InsertUniqueI16(__sdk::spacetime_module::parse_reducer_args( - "insert_unique_i16", - &value.args, - )?)), - "insert_unique_i256" => Ok(Reducer::InsertUniqueI256(__sdk::spacetime_module::parse_reducer_args( - "insert_unique_i256", - &value.args, - )?)), - "insert_unique_i32" => Ok(Reducer::InsertUniqueI32(__sdk::spacetime_module::parse_reducer_args( - "insert_unique_i32", - &value.args, - )?)), - "insert_unique_i64" => Ok(Reducer::InsertUniqueI64(__sdk::spacetime_module::parse_reducer_args( - "insert_unique_i64", - &value.args, - )?)), - "insert_unique_i8" => Ok(Reducer::InsertUniqueI8(__sdk::spacetime_module::parse_reducer_args( - "insert_unique_i8", - &value.args, - )?)), - "insert_unique_identity" => Ok(Reducer::InsertUniqueIdentity( - __sdk::spacetime_module::parse_reducer_args("insert_unique_identity", &value.args)?, - )), - "insert_unique_string" => Ok(Reducer::InsertUniqueString( - __sdk::spacetime_module::parse_reducer_args("insert_unique_string", &value.args)?, - )), - "insert_unique_u128" => Ok(Reducer::InsertUniqueU128(__sdk::spacetime_module::parse_reducer_args( - "insert_unique_u128", - &value.args, - )?)), - "insert_unique_u16" => Ok(Reducer::InsertUniqueU16(__sdk::spacetime_module::parse_reducer_args( - "insert_unique_u16", - &value.args, - )?)), - "insert_unique_u256" => Ok(Reducer::InsertUniqueU256(__sdk::spacetime_module::parse_reducer_args( - "insert_unique_u256", - &value.args, - )?)), - "insert_unique_u32" => Ok(Reducer::InsertUniqueU32(__sdk::spacetime_module::parse_reducer_args( - "insert_unique_u32", - &value.args, - )?)), - "insert_unique_u64" => Ok(Reducer::InsertUniqueU64(__sdk::spacetime_module::parse_reducer_args( - "insert_unique_u64", - &value.args, - )?)), - "insert_unique_u8" => Ok(Reducer::InsertUniqueU8(__sdk::spacetime_module::parse_reducer_args( - "insert_unique_u8", - &value.args, - )?)), - "insert_vec_address" => Ok(Reducer::InsertVecAddress(__sdk::spacetime_module::parse_reducer_args( - "insert_vec_address", - &value.args, - )?)), - "insert_vec_bool" => Ok(Reducer::InsertVecBool(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_primitives_as_strings" => Ok(__sdk::parse_reducer_args::< + insert_primitives_as_strings_reducer::InsertPrimitivesAsStringsArgs, + >("insert_primitives_as_strings", &value.args)? + .into()), + "insert_table_holds_table" => Ok(__sdk::parse_reducer_args::< + insert_table_holds_table_reducer::InsertTableHoldsTableArgs, + >("insert_table_holds_table", &value.args)? + .into()), + "insert_unique_address" => Ok(__sdk::parse_reducer_args::< + insert_unique_address_reducer::InsertUniqueAddressArgs, + >("insert_unique_address", &value.args)? + .into()), + "insert_unique_bool" => Ok( + __sdk::parse_reducer_args::( + "insert_unique_bool", + &value.args, + )? + .into(), + ), + "insert_unique_i128" => Ok( + __sdk::parse_reducer_args::( + "insert_unique_i128", + &value.args, + )? + .into(), + ), + "insert_unique_i16" => Ok( + __sdk::parse_reducer_args::( + "insert_unique_i16", + &value.args, + )? + .into(), + ), + "insert_unique_i256" => Ok( + __sdk::parse_reducer_args::( + "insert_unique_i256", + &value.args, + )? + .into(), + ), + "insert_unique_i32" => Ok( + __sdk::parse_reducer_args::( + "insert_unique_i32", + &value.args, + )? + .into(), + ), + "insert_unique_i64" => Ok( + __sdk::parse_reducer_args::( + "insert_unique_i64", + &value.args, + )? + .into(), + ), + "insert_unique_i8" => Ok( + __sdk::parse_reducer_args::( + "insert_unique_i8", + &value.args, + )? + .into(), + ), + "insert_unique_identity" => Ok(__sdk::parse_reducer_args::< + insert_unique_identity_reducer::InsertUniqueIdentityArgs, + >("insert_unique_identity", &value.args)? + .into()), + "insert_unique_string" => Ok(__sdk::parse_reducer_args::< + insert_unique_string_reducer::InsertUniqueStringArgs, + >("insert_unique_string", &value.args)? + .into()), + "insert_unique_u128" => Ok( + __sdk::parse_reducer_args::( + "insert_unique_u128", + &value.args, + )? + .into(), + ), + "insert_unique_u16" => Ok( + __sdk::parse_reducer_args::( + "insert_unique_u16", + &value.args, + )? + .into(), + ), + "insert_unique_u256" => Ok( + __sdk::parse_reducer_args::( + "insert_unique_u256", + &value.args, + )? + .into(), + ), + "insert_unique_u32" => Ok( + __sdk::parse_reducer_args::( + "insert_unique_u32", + &value.args, + )? + .into(), + ), + "insert_unique_u64" => Ok( + __sdk::parse_reducer_args::( + "insert_unique_u64", + &value.args, + )? + .into(), + ), + "insert_unique_u8" => Ok( + __sdk::parse_reducer_args::( + "insert_unique_u8", + &value.args, + )? + .into(), + ), + "insert_vec_address" => Ok( + __sdk::parse_reducer_args::( + "insert_vec_address", + &value.args, + )? + .into(), + ), + "insert_vec_bool" => Ok(__sdk::parse_reducer_args::( "insert_vec_bool", &value.args, - )?)), - "insert_vec_byte_struct" => Ok(Reducer::InsertVecByteStruct( - __sdk::spacetime_module::parse_reducer_args("insert_vec_byte_struct", &value.args)?, - )), - "insert_vec_enum_with_payload" => Ok(Reducer::InsertVecEnumWithPayload( - __sdk::spacetime_module::parse_reducer_args("insert_vec_enum_with_payload", &value.args)?, - )), - "insert_vec_every_primitive_struct" => Ok(Reducer::InsertVecEveryPrimitiveStruct( - __sdk::spacetime_module::parse_reducer_args("insert_vec_every_primitive_struct", &value.args)?, - )), - "insert_vec_every_vec_struct" => Ok(Reducer::InsertVecEveryVecStruct( - __sdk::spacetime_module::parse_reducer_args("insert_vec_every_vec_struct", &value.args)?, - )), - "insert_vec_f32" => Ok(Reducer::InsertVecF32(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_vec_byte_struct" => Ok(__sdk::parse_reducer_args::< + insert_vec_byte_struct_reducer::InsertVecByteStructArgs, + >("insert_vec_byte_struct", &value.args)? + .into()), + "insert_vec_enum_with_payload" => Ok(__sdk::parse_reducer_args::< + insert_vec_enum_with_payload_reducer::InsertVecEnumWithPayloadArgs, + >("insert_vec_enum_with_payload", &value.args)? + .into()), + "insert_vec_every_primitive_struct" => Ok(__sdk::parse_reducer_args::< + insert_vec_every_primitive_struct_reducer::InsertVecEveryPrimitiveStructArgs, + >("insert_vec_every_primitive_struct", &value.args)? + .into()), + "insert_vec_every_vec_struct" => Ok(__sdk::parse_reducer_args::< + insert_vec_every_vec_struct_reducer::InsertVecEveryVecStructArgs, + >("insert_vec_every_vec_struct", &value.args)? + .into()), + "insert_vec_f32" => Ok(__sdk::parse_reducer_args::( "insert_vec_f32", &value.args, - )?)), - "insert_vec_f64" => Ok(Reducer::InsertVecF64(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_vec_f64" => Ok(__sdk::parse_reducer_args::( "insert_vec_f64", &value.args, - )?)), - "insert_vec_i128" => Ok(Reducer::InsertVecI128(__sdk::spacetime_module::parse_reducer_args( - "insert_vec_i128", - &value.args, - )?)), - "insert_vec_i16" => Ok(Reducer::InsertVecI16(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_vec_i128" => Ok( + __sdk::parse_reducer_args::( + "insert_vec_i128", + &value.args, + )? + .into(), + ), + "insert_vec_i16" => Ok(__sdk::parse_reducer_args::( "insert_vec_i16", &value.args, - )?)), - "insert_vec_i256" => Ok(Reducer::InsertVecI256(__sdk::spacetime_module::parse_reducer_args( - "insert_vec_i256", - &value.args, - )?)), - "insert_vec_i32" => Ok(Reducer::InsertVecI32(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_vec_i256" => Ok( + __sdk::parse_reducer_args::( + "insert_vec_i256", + &value.args, + )? + .into(), + ), + "insert_vec_i32" => Ok(__sdk::parse_reducer_args::( "insert_vec_i32", &value.args, - )?)), - "insert_vec_i64" => Ok(Reducer::InsertVecI64(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_vec_i64" => Ok(__sdk::parse_reducer_args::( "insert_vec_i64", &value.args, - )?)), - "insert_vec_i8" => Ok(Reducer::InsertVecI8(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_vec_i8" => Ok(__sdk::parse_reducer_args::( "insert_vec_i8", &value.args, - )?)), - "insert_vec_identity" => Ok(Reducer::InsertVecIdentity(__sdk::spacetime_module::parse_reducer_args( - "insert_vec_identity", - &value.args, - )?)), - "insert_vec_simple_enum" => Ok(Reducer::InsertVecSimpleEnum( - __sdk::spacetime_module::parse_reducer_args("insert_vec_simple_enum", &value.args)?, - )), - "insert_vec_string" => Ok(Reducer::InsertVecString(__sdk::spacetime_module::parse_reducer_args( - "insert_vec_string", - &value.args, - )?)), - "insert_vec_u128" => Ok(Reducer::InsertVecU128(__sdk::spacetime_module::parse_reducer_args( - "insert_vec_u128", - &value.args, - )?)), - "insert_vec_u16" => Ok(Reducer::InsertVecU16(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_vec_identity" => Ok( + __sdk::parse_reducer_args::( + "insert_vec_identity", + &value.args, + )? + .into(), + ), + "insert_vec_simple_enum" => Ok(__sdk::parse_reducer_args::< + insert_vec_simple_enum_reducer::InsertVecSimpleEnumArgs, + >("insert_vec_simple_enum", &value.args)? + .into()), + "insert_vec_string" => Ok( + __sdk::parse_reducer_args::( + "insert_vec_string", + &value.args, + )? + .into(), + ), + "insert_vec_u128" => Ok( + __sdk::parse_reducer_args::( + "insert_vec_u128", + &value.args, + )? + .into(), + ), + "insert_vec_u16" => Ok(__sdk::parse_reducer_args::( "insert_vec_u16", &value.args, - )?)), - "insert_vec_u256" => Ok(Reducer::InsertVecU256(__sdk::spacetime_module::parse_reducer_args( - "insert_vec_u256", - &value.args, - )?)), - "insert_vec_u32" => Ok(Reducer::InsertVecU32(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_vec_u256" => Ok( + __sdk::parse_reducer_args::( + "insert_vec_u256", + &value.args, + )? + .into(), + ), + "insert_vec_u32" => Ok(__sdk::parse_reducer_args::( "insert_vec_u32", &value.args, - )?)), - "insert_vec_u64" => Ok(Reducer::InsertVecU64(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_vec_u64" => Ok(__sdk::parse_reducer_args::( "insert_vec_u64", &value.args, - )?)), - "insert_vec_u8" => Ok(Reducer::InsertVecU8(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_vec_u8" => Ok(__sdk::parse_reducer_args::( "insert_vec_u8", &value.args, - )?)), - "insert_vec_unit_struct" => Ok(Reducer::InsertVecUnitStruct( - __sdk::spacetime_module::parse_reducer_args("insert_vec_unit_struct", &value.args)?, - )), - "no_op_succeeds" => Ok(Reducer::NoOpSucceeds(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "insert_vec_unit_struct" => Ok(__sdk::parse_reducer_args::< + insert_vec_unit_struct_reducer::InsertVecUnitStructArgs, + >("insert_vec_unit_struct", &value.args)? + .into()), + "no_op_succeeds" => Ok(__sdk::parse_reducer_args::( "no_op_succeeds", &value.args, - )?)), - "update_pk_address" => Ok(Reducer::UpdatePkAddress(__sdk::spacetime_module::parse_reducer_args( - "update_pk_address", - &value.args, - )?)), - "update_pk_bool" => Ok(Reducer::UpdatePkBool(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "send_scheduled_message" => Ok(__sdk::parse_reducer_args::< + send_scheduled_message_reducer::SendScheduledMessageArgs, + >("send_scheduled_message", &value.args)? + .into()), + "update_pk_address" => Ok( + __sdk::parse_reducer_args::( + "update_pk_address", + &value.args, + )? + .into(), + ), + "update_pk_bool" => Ok(__sdk::parse_reducer_args::( "update_pk_bool", &value.args, - )?)), - "update_pk_i128" => Ok(Reducer::UpdatePkI128(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "update_pk_i128" => Ok(__sdk::parse_reducer_args::( "update_pk_i128", &value.args, - )?)), - "update_pk_i16" => Ok(Reducer::UpdatePkI16(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "update_pk_i16" => Ok(__sdk::parse_reducer_args::( "update_pk_i16", &value.args, - )?)), - "update_pk_i256" => Ok(Reducer::UpdatePkI256(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "update_pk_i256" => Ok(__sdk::parse_reducer_args::( "update_pk_i256", &value.args, - )?)), - "update_pk_i32" => Ok(Reducer::UpdatePkI32(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "update_pk_i32" => Ok(__sdk::parse_reducer_args::( "update_pk_i32", &value.args, - )?)), - "update_pk_i64" => Ok(Reducer::UpdatePkI64(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "update_pk_i64" => Ok(__sdk::parse_reducer_args::( "update_pk_i64", &value.args, - )?)), - "update_pk_i8" => Ok(Reducer::UpdatePkI8(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "update_pk_i8" => Ok(__sdk::parse_reducer_args::( "update_pk_i8", &value.args, - )?)), - "update_pk_identity" => Ok(Reducer::UpdatePkIdentity(__sdk::spacetime_module::parse_reducer_args( - "update_pk_identity", - &value.args, - )?)), - "update_pk_string" => Ok(Reducer::UpdatePkString(__sdk::spacetime_module::parse_reducer_args( - "update_pk_string", - &value.args, - )?)), - "update_pk_u128" => Ok(Reducer::UpdatePkU128(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "update_pk_identity" => Ok( + __sdk::parse_reducer_args::( + "update_pk_identity", + &value.args, + )? + .into(), + ), + "update_pk_string" => Ok( + __sdk::parse_reducer_args::( + "update_pk_string", + &value.args, + )? + .into(), + ), + "update_pk_u128" => Ok(__sdk::parse_reducer_args::( "update_pk_u128", &value.args, - )?)), - "update_pk_u16" => Ok(Reducer::UpdatePkU16(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "update_pk_u16" => Ok(__sdk::parse_reducer_args::( "update_pk_u16", &value.args, - )?)), - "update_pk_u256" => Ok(Reducer::UpdatePkU256(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "update_pk_u256" => Ok(__sdk::parse_reducer_args::( "update_pk_u256", &value.args, - )?)), - "update_pk_u32" => Ok(Reducer::UpdatePkU32(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "update_pk_u32" => Ok(__sdk::parse_reducer_args::( "update_pk_u32", &value.args, - )?)), - "update_pk_u64" => Ok(Reducer::UpdatePkU64(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "update_pk_u64" => Ok(__sdk::parse_reducer_args::( "update_pk_u64", &value.args, - )?)), - "update_pk_u8" => Ok(Reducer::UpdatePkU8(__sdk::spacetime_module::parse_reducer_args( + )? + .into()), + "update_pk_u8" => Ok(__sdk::parse_reducer_args::( "update_pk_u8", &value.args, - )?)), - "update_unique_address" => Ok(Reducer::UpdateUniqueAddress( - __sdk::spacetime_module::parse_reducer_args("update_unique_address", &value.args)?, - )), - "update_unique_bool" => Ok(Reducer::UpdateUniqueBool(__sdk::spacetime_module::parse_reducer_args( - "update_unique_bool", - &value.args, - )?)), - "update_unique_i128" => Ok(Reducer::UpdateUniqueI128(__sdk::spacetime_module::parse_reducer_args( - "update_unique_i128", - &value.args, - )?)), - "update_unique_i16" => Ok(Reducer::UpdateUniqueI16(__sdk::spacetime_module::parse_reducer_args( - "update_unique_i16", - &value.args, - )?)), - "update_unique_i256" => Ok(Reducer::UpdateUniqueI256(__sdk::spacetime_module::parse_reducer_args( - "update_unique_i256", - &value.args, - )?)), - "update_unique_i32" => Ok(Reducer::UpdateUniqueI32(__sdk::spacetime_module::parse_reducer_args( - "update_unique_i32", - &value.args, - )?)), - "update_unique_i64" => Ok(Reducer::UpdateUniqueI64(__sdk::spacetime_module::parse_reducer_args( - "update_unique_i64", - &value.args, - )?)), - "update_unique_i8" => Ok(Reducer::UpdateUniqueI8(__sdk::spacetime_module::parse_reducer_args( - "update_unique_i8", - &value.args, - )?)), - "update_unique_identity" => Ok(Reducer::UpdateUniqueIdentity( - __sdk::spacetime_module::parse_reducer_args("update_unique_identity", &value.args)?, - )), - "update_unique_string" => Ok(Reducer::UpdateUniqueString( - __sdk::spacetime_module::parse_reducer_args("update_unique_string", &value.args)?, - )), - "update_unique_u128" => Ok(Reducer::UpdateUniqueU128(__sdk::spacetime_module::parse_reducer_args( - "update_unique_u128", - &value.args, - )?)), - "update_unique_u16" => Ok(Reducer::UpdateUniqueU16(__sdk::spacetime_module::parse_reducer_args( - "update_unique_u16", - &value.args, - )?)), - "update_unique_u256" => Ok(Reducer::UpdateUniqueU256(__sdk::spacetime_module::parse_reducer_args( - "update_unique_u256", - &value.args, - )?)), - "update_unique_u32" => Ok(Reducer::UpdateUniqueU32(__sdk::spacetime_module::parse_reducer_args( - "update_unique_u32", - &value.args, - )?)), - "update_unique_u64" => Ok(Reducer::UpdateUniqueU64(__sdk::spacetime_module::parse_reducer_args( - "update_unique_u64", - &value.args, - )?)), - "update_unique_u8" => Ok(Reducer::UpdateUniqueU8(__sdk::spacetime_module::parse_reducer_args( - "update_unique_u8", - &value.args, - )?)), + )? + .into()), + "update_unique_address" => Ok(__sdk::parse_reducer_args::< + update_unique_address_reducer::UpdateUniqueAddressArgs, + >("update_unique_address", &value.args)? + .into()), + "update_unique_bool" => Ok( + __sdk::parse_reducer_args::( + "update_unique_bool", + &value.args, + )? + .into(), + ), + "update_unique_i128" => Ok( + __sdk::parse_reducer_args::( + "update_unique_i128", + &value.args, + )? + .into(), + ), + "update_unique_i16" => Ok( + __sdk::parse_reducer_args::( + "update_unique_i16", + &value.args, + )? + .into(), + ), + "update_unique_i256" => Ok( + __sdk::parse_reducer_args::( + "update_unique_i256", + &value.args, + )? + .into(), + ), + "update_unique_i32" => Ok( + __sdk::parse_reducer_args::( + "update_unique_i32", + &value.args, + )? + .into(), + ), + "update_unique_i64" => Ok( + __sdk::parse_reducer_args::( + "update_unique_i64", + &value.args, + )? + .into(), + ), + "update_unique_i8" => Ok( + __sdk::parse_reducer_args::( + "update_unique_i8", + &value.args, + )? + .into(), + ), + "update_unique_identity" => Ok(__sdk::parse_reducer_args::< + update_unique_identity_reducer::UpdateUniqueIdentityArgs, + >("update_unique_identity", &value.args)? + .into()), + "update_unique_string" => Ok(__sdk::parse_reducer_args::< + update_unique_string_reducer::UpdateUniqueStringArgs, + >("update_unique_string", &value.args)? + .into()), + "update_unique_u128" => Ok( + __sdk::parse_reducer_args::( + "update_unique_u128", + &value.args, + )? + .into(), + ), + "update_unique_u16" => Ok( + __sdk::parse_reducer_args::( + "update_unique_u16", + &value.args, + )? + .into(), + ), + "update_unique_u256" => Ok( + __sdk::parse_reducer_args::( + "update_unique_u256", + &value.args, + )? + .into(), + ), + "update_unique_u32" => Ok( + __sdk::parse_reducer_args::( + "update_unique_u32", + &value.args, + )? + .into(), + ), + "update_unique_u64" => Ok( + __sdk::parse_reducer_args::( + "update_unique_u64", + &value.args, + )? + .into(), + ), + "update_unique_u8" => Ok( + __sdk::parse_reducer_args::( + "update_unique_u8", + &value.args, + )? + .into(), + ), _ => Err(__anyhow::anyhow!("Unknown reducer {:?}", value.reducer_name)), } } @@ -1834,94 +2503,97 @@ impl TryFrom<__ws::ReducerCallInfo<__ws::BsatnFormat>> for Reducer { #[allow(non_snake_case)] #[doc(hidden)] pub struct DbUpdate { - large_table: __sdk::spacetime_module::TableUpdate, - one_address: __sdk::spacetime_module::TableUpdate, - one_bool: __sdk::spacetime_module::TableUpdate, - one_byte_struct: __sdk::spacetime_module::TableUpdate, - one_enum_with_payload: __sdk::spacetime_module::TableUpdate, - one_every_primitive_struct: __sdk::spacetime_module::TableUpdate, - one_every_vec_struct: __sdk::spacetime_module::TableUpdate, - one_f_32: __sdk::spacetime_module::TableUpdate, - one_f_64: __sdk::spacetime_module::TableUpdate, - one_i_128: __sdk::spacetime_module::TableUpdate, - one_i_16: __sdk::spacetime_module::TableUpdate, - one_i_256: __sdk::spacetime_module::TableUpdate, - one_i_32: __sdk::spacetime_module::TableUpdate, - one_i_64: __sdk::spacetime_module::TableUpdate, - one_i_8: __sdk::spacetime_module::TableUpdate, - one_identity: __sdk::spacetime_module::TableUpdate, - one_simple_enum: __sdk::spacetime_module::TableUpdate, - one_string: __sdk::spacetime_module::TableUpdate, - one_u_128: __sdk::spacetime_module::TableUpdate, - one_u_16: __sdk::spacetime_module::TableUpdate, - one_u_256: __sdk::spacetime_module::TableUpdate, - one_u_32: __sdk::spacetime_module::TableUpdate, - one_u_64: __sdk::spacetime_module::TableUpdate, - one_u_8: __sdk::spacetime_module::TableUpdate, - one_unit_struct: __sdk::spacetime_module::TableUpdate, - option_every_primitive_struct: __sdk::spacetime_module::TableUpdate, - option_i_32: __sdk::spacetime_module::TableUpdate, - option_identity: __sdk::spacetime_module::TableUpdate, - option_simple_enum: __sdk::spacetime_module::TableUpdate, - option_string: __sdk::spacetime_module::TableUpdate, - option_vec_option_i_32: __sdk::spacetime_module::TableUpdate, - pk_address: __sdk::spacetime_module::TableUpdate, - pk_bool: __sdk::spacetime_module::TableUpdate, - pk_i_128: __sdk::spacetime_module::TableUpdate, - pk_i_16: __sdk::spacetime_module::TableUpdate, - pk_i_256: __sdk::spacetime_module::TableUpdate, - pk_i_32: __sdk::spacetime_module::TableUpdate, - pk_i_64: __sdk::spacetime_module::TableUpdate, - pk_i_8: __sdk::spacetime_module::TableUpdate, - pk_identity: __sdk::spacetime_module::TableUpdate, - pk_string: __sdk::spacetime_module::TableUpdate, - pk_u_128: __sdk::spacetime_module::TableUpdate, - pk_u_16: __sdk::spacetime_module::TableUpdate, - pk_u_256: __sdk::spacetime_module::TableUpdate, - pk_u_32: __sdk::spacetime_module::TableUpdate, - pk_u_64: __sdk::spacetime_module::TableUpdate, - pk_u_8: __sdk::spacetime_module::TableUpdate, - table_holds_table: __sdk::spacetime_module::TableUpdate, - unique_address: __sdk::spacetime_module::TableUpdate, - unique_bool: __sdk::spacetime_module::TableUpdate, - unique_i_128: __sdk::spacetime_module::TableUpdate, - unique_i_16: __sdk::spacetime_module::TableUpdate, - unique_i_256: __sdk::spacetime_module::TableUpdate, - unique_i_32: __sdk::spacetime_module::TableUpdate, - unique_i_64: __sdk::spacetime_module::TableUpdate, - unique_i_8: __sdk::spacetime_module::TableUpdate, - unique_identity: __sdk::spacetime_module::TableUpdate, - unique_string: __sdk::spacetime_module::TableUpdate, - unique_u_128: __sdk::spacetime_module::TableUpdate, - unique_u_16: __sdk::spacetime_module::TableUpdate, - unique_u_256: __sdk::spacetime_module::TableUpdate, - unique_u_32: __sdk::spacetime_module::TableUpdate, - unique_u_64: __sdk::spacetime_module::TableUpdate, - unique_u_8: __sdk::spacetime_module::TableUpdate, - vec_address: __sdk::spacetime_module::TableUpdate, - vec_bool: __sdk::spacetime_module::TableUpdate, - vec_byte_struct: __sdk::spacetime_module::TableUpdate, - vec_enum_with_payload: __sdk::spacetime_module::TableUpdate, - vec_every_primitive_struct: __sdk::spacetime_module::TableUpdate, - vec_every_vec_struct: __sdk::spacetime_module::TableUpdate, - vec_f_32: __sdk::spacetime_module::TableUpdate, - vec_f_64: __sdk::spacetime_module::TableUpdate, - vec_i_128: __sdk::spacetime_module::TableUpdate, - vec_i_16: __sdk::spacetime_module::TableUpdate, - vec_i_256: __sdk::spacetime_module::TableUpdate, - vec_i_32: __sdk::spacetime_module::TableUpdate, - vec_i_64: __sdk::spacetime_module::TableUpdate, - vec_i_8: __sdk::spacetime_module::TableUpdate, - vec_identity: __sdk::spacetime_module::TableUpdate, - vec_simple_enum: __sdk::spacetime_module::TableUpdate, - vec_string: __sdk::spacetime_module::TableUpdate, - vec_u_128: __sdk::spacetime_module::TableUpdate, - vec_u_16: __sdk::spacetime_module::TableUpdate, - vec_u_256: __sdk::spacetime_module::TableUpdate, - vec_u_32: __sdk::spacetime_module::TableUpdate, - vec_u_64: __sdk::spacetime_module::TableUpdate, - vec_u_8: __sdk::spacetime_module::TableUpdate, - vec_unit_struct: __sdk::spacetime_module::TableUpdate, + indexed_table: __sdk::TableUpdate, + indexed_table_2: __sdk::TableUpdate, + large_table: __sdk::TableUpdate, + one_address: __sdk::TableUpdate, + one_bool: __sdk::TableUpdate, + one_byte_struct: __sdk::TableUpdate, + one_enum_with_payload: __sdk::TableUpdate, + one_every_primitive_struct: __sdk::TableUpdate, + one_every_vec_struct: __sdk::TableUpdate, + one_f_32: __sdk::TableUpdate, + one_f_64: __sdk::TableUpdate, + one_i_128: __sdk::TableUpdate, + one_i_16: __sdk::TableUpdate, + one_i_256: __sdk::TableUpdate, + one_i_32: __sdk::TableUpdate, + one_i_64: __sdk::TableUpdate, + one_i_8: __sdk::TableUpdate, + one_identity: __sdk::TableUpdate, + one_simple_enum: __sdk::TableUpdate, + one_string: __sdk::TableUpdate, + one_u_128: __sdk::TableUpdate, + one_u_16: __sdk::TableUpdate, + one_u_256: __sdk::TableUpdate, + one_u_32: __sdk::TableUpdate, + one_u_64: __sdk::TableUpdate, + one_u_8: __sdk::TableUpdate, + one_unit_struct: __sdk::TableUpdate, + option_every_primitive_struct: __sdk::TableUpdate, + option_i_32: __sdk::TableUpdate, + option_identity: __sdk::TableUpdate, + option_simple_enum: __sdk::TableUpdate, + option_string: __sdk::TableUpdate, + option_vec_option_i_32: __sdk::TableUpdate, + pk_address: __sdk::TableUpdate, + pk_bool: __sdk::TableUpdate, + pk_i_128: __sdk::TableUpdate, + pk_i_16: __sdk::TableUpdate, + pk_i_256: __sdk::TableUpdate, + pk_i_32: __sdk::TableUpdate, + pk_i_64: __sdk::TableUpdate, + pk_i_8: __sdk::TableUpdate, + pk_identity: __sdk::TableUpdate, + pk_string: __sdk::TableUpdate, + pk_u_128: __sdk::TableUpdate, + pk_u_16: __sdk::TableUpdate, + pk_u_256: __sdk::TableUpdate, + pk_u_32: __sdk::TableUpdate, + pk_u_64: __sdk::TableUpdate, + pk_u_8: __sdk::TableUpdate, + scheduled_table: __sdk::TableUpdate, + table_holds_table: __sdk::TableUpdate, + unique_address: __sdk::TableUpdate, + unique_bool: __sdk::TableUpdate, + unique_i_128: __sdk::TableUpdate, + unique_i_16: __sdk::TableUpdate, + unique_i_256: __sdk::TableUpdate, + unique_i_32: __sdk::TableUpdate, + unique_i_64: __sdk::TableUpdate, + unique_i_8: __sdk::TableUpdate, + unique_identity: __sdk::TableUpdate, + unique_string: __sdk::TableUpdate, + unique_u_128: __sdk::TableUpdate, + unique_u_16: __sdk::TableUpdate, + unique_u_256: __sdk::TableUpdate, + unique_u_32: __sdk::TableUpdate, + unique_u_64: __sdk::TableUpdate, + unique_u_8: __sdk::TableUpdate, + vec_address: __sdk::TableUpdate, + vec_bool: __sdk::TableUpdate, + vec_byte_struct: __sdk::TableUpdate, + vec_enum_with_payload: __sdk::TableUpdate, + vec_every_primitive_struct: __sdk::TableUpdate, + vec_every_vec_struct: __sdk::TableUpdate, + vec_f_32: __sdk::TableUpdate, + vec_f_64: __sdk::TableUpdate, + vec_i_128: __sdk::TableUpdate, + vec_i_16: __sdk::TableUpdate, + vec_i_256: __sdk::TableUpdate, + vec_i_32: __sdk::TableUpdate, + vec_i_64: __sdk::TableUpdate, + vec_i_8: __sdk::TableUpdate, + vec_identity: __sdk::TableUpdate, + vec_simple_enum: __sdk::TableUpdate, + vec_string: __sdk::TableUpdate, + vec_u_128: __sdk::TableUpdate, + vec_u_16: __sdk::TableUpdate, + vec_u_256: __sdk::TableUpdate, + vec_u_32: __sdk::TableUpdate, + vec_u_64: __sdk::TableUpdate, + vec_u_8: __sdk::TableUpdate, + vec_unit_struct: __sdk::TableUpdate, } impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate { @@ -1930,6 +2602,10 @@ impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate { let mut db_update = DbUpdate::default(); for table_update in raw.tables { match &table_update.table_name[..] { + "indexed_table" => db_update.indexed_table = indexed_table_table::parse_table_update(table_update)?, + "indexed_table_2" => { + db_update.indexed_table_2 = indexed_table_2_table::parse_table_update(table_update)? + } "large_table" => db_update.large_table = large_table_table::parse_table_update(table_update)?, "one_address" => db_update.one_address = one_address_table::parse_table_update(table_update)?, "one_bool" => db_update.one_bool = one_bool_table::parse_table_update(table_update)?, @@ -1999,6 +2675,9 @@ impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate { "pk_u32" => db_update.pk_u_32 = pk_u_32_table::parse_table_update(table_update)?, "pk_u64" => db_update.pk_u_64 = pk_u_64_table::parse_table_update(table_update)?, "pk_u8" => db_update.pk_u_8 = pk_u_8_table::parse_table_update(table_update)?, + "scheduled_table" => { + db_update.scheduled_table = scheduled_table_table::parse_table_update(table_update)? + } "table_holds_table" => { db_update.table_holds_table = table_holds_table_table::parse_table_update(table_update)? } @@ -2065,12 +2744,14 @@ impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate { } } -impl __sdk::spacetime_module::InModule for DbUpdate { +impl __sdk::InModule for DbUpdate { type Module = RemoteModule; } -impl __sdk::spacetime_module::DbUpdate for DbUpdate { - fn apply_to_client_cache(&self, cache: &mut __sdk::client_cache::ClientCache) { +impl __sdk::DbUpdate for DbUpdate { + fn apply_to_client_cache(&self, cache: &mut __sdk::ClientCache) { + cache.apply_diff_to_table::("indexed_table", &self.indexed_table); + cache.apply_diff_to_table::("indexed_table_2", &self.indexed_table_2); cache.apply_diff_to_table::("large_table", &self.large_table); cache.apply_diff_to_table::("one_address", &self.one_address); cache.apply_diff_to_table::("one_bool", &self.one_bool); @@ -2124,6 +2805,7 @@ impl __sdk::spacetime_module::DbUpdate for DbUpdate { cache.apply_diff_to_table::("pk_u32", &self.pk_u_32); cache.apply_diff_to_table::("pk_u64", &self.pk_u_64); cache.apply_diff_to_table::("pk_u8", &self.pk_u_8); + cache.apply_diff_to_table::("scheduled_table", &self.scheduled_table); cache.apply_diff_to_table::("table_holds_table", &self.table_holds_table); cache.apply_diff_to_table::("unique_address", &self.unique_address); cache.apply_diff_to_table::("unique_bool", &self.unique_bool); @@ -2169,7 +2851,9 @@ impl __sdk::spacetime_module::DbUpdate for DbUpdate { cache.apply_diff_to_table::("vec_u8", &self.vec_u_8); cache.apply_diff_to_table::("vec_unit_struct", &self.vec_unit_struct); } - fn invoke_row_callbacks(&self, event: &EventContext, callbacks: &mut __sdk::callbacks::DbCallbacks) { + fn invoke_row_callbacks(&self, event: &EventContext, callbacks: &mut __sdk::DbCallbacks) { + callbacks.invoke_table_row_callbacks::("indexed_table", &self.indexed_table, event); + callbacks.invoke_table_row_callbacks::("indexed_table_2", &self.indexed_table_2, event); callbacks.invoke_table_row_callbacks::("large_table", &self.large_table, event); callbacks.invoke_table_row_callbacks::("one_address", &self.one_address, event); callbacks.invoke_table_row_callbacks::("one_bool", &self.one_bool, event); @@ -2237,6 +2921,7 @@ impl __sdk::spacetime_module::DbUpdate for DbUpdate { callbacks.invoke_table_row_callbacks::("pk_u32", &self.pk_u_32, event); callbacks.invoke_table_row_callbacks::("pk_u64", &self.pk_u_64, event); callbacks.invoke_table_row_callbacks::("pk_u8", &self.pk_u_8, event); + callbacks.invoke_table_row_callbacks::("scheduled_table", &self.scheduled_table, event); callbacks.invoke_table_row_callbacks::("table_holds_table", &self.table_holds_table, event); callbacks.invoke_table_row_callbacks::("unique_address", &self.unique_address, event); callbacks.invoke_table_row_callbacks::("unique_bool", &self.unique_bool, event); @@ -2296,28 +2981,17 @@ impl __sdk::spacetime_module::DbUpdate for DbUpdate { #[doc(hidden)] pub struct RemoteModule; -impl __sdk::spacetime_module::InModule for RemoteModule { +impl __sdk::InModule for RemoteModule { type Module = Self; } -impl __sdk::spacetime_module::SpacetimeModule for RemoteModule { - type DbConnection = DbConnection; - type EventContext = EventContext; - type Reducer = Reducer; - type DbView = RemoteTables; - type Reducers = RemoteReducers; - type SetReducerFlags = SetReducerFlags; - type DbUpdate = DbUpdate; - type SubscriptionHandle = SubscriptionHandle; -} - /// The `reducers` field of [`EventContext`] and [`DbConnection`], /// with methods provided by extension traits for each reducer defined by the module. pub struct RemoteReducers { - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for RemoteReducers { +impl __sdk::InModule for RemoteReducers { type Module = RemoteModule; } @@ -2328,20 +3002,20 @@ impl __sdk::spacetime_module::InModule for RemoteReducers { /// /// This type is currently unstable and may be removed without a major version bump. pub struct SetReducerFlags { - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for SetReducerFlags { +impl __sdk::InModule for SetReducerFlags { type Module = RemoteModule; } /// The `db` field of [`EventContext`] and [`DbConnection`], /// with methods provided by extension traits for each table defined by the module. pub struct RemoteTables { - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for RemoteTables { +impl __sdk::InModule for RemoteTables { type Module = RemoteModule; } @@ -2373,14 +3047,14 @@ pub struct DbConnection { /// This type is currently unstable and may be removed without a major version bump. pub set_reducer_flags: SetReducerFlags, - imp: __sdk::db_connection::DbContextImpl, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for DbConnection { +impl __sdk::InModule for DbConnection { type Module = RemoteModule; } -impl __sdk::db_context::DbContext for DbConnection { +impl __sdk::DbContext for DbConnection { type DbView = RemoteTables; type Reducers = RemoteReducers; type SetReducerFlags = SetReducerFlags; @@ -2403,10 +3077,10 @@ impl __sdk::db_context::DbContext for DbConnection { self.imp.disconnect() } - type SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder; + type SubscriptionBuilder = __sdk::SubscriptionBuilder; fn subscription_builder(&self) -> Self::SubscriptionBuilder { - __sdk::subscription::SubscriptionBuilder::new(&self.imp) + __sdk::SubscriptionBuilder::new(&self.imp) } fn try_identity(&self) -> Option<__sdk::Identity> { @@ -2422,7 +3096,7 @@ impl DbConnection { /// /// See [`__sdk::DbConnectionBuilder`] for required and optional configuration for the new connection. pub fn builder() -> __sdk::DbConnectionBuilder { - __sdk::db_connection::DbConnectionBuilder::new() + __sdk::DbConnectionBuilder::new() } /// If any WebSocket messages are waiting, process one of them. @@ -2488,8 +3162,8 @@ impl DbConnection { } } -impl __sdk::spacetime_module::DbConnection for DbConnection { - fn new(imp: __sdk::db_connection::DbContextImpl) -> Self { +impl __sdk::DbConnection for DbConnection { + fn new(imp: __sdk::DbContextImpl) -> Self { Self { db: RemoteTables { imp: imp.clone() }, reducers: RemoteReducers { imp: imp.clone() }, @@ -2512,15 +3186,15 @@ pub struct EventContext { /// This type is currently unstable and may be removed without a major version bump. pub set_reducer_flags: SetReducerFlags, /// The event which caused these callbacks to run. - pub event: __sdk::event::Event, - imp: __sdk::db_connection::DbContextImpl, + pub event: __sdk::Event, + imp: __sdk::DbContextImpl, } -impl __sdk::spacetime_module::InModule for EventContext { +impl __sdk::InModule for EventContext { type Module = RemoteModule; } -impl __sdk::db_context::DbContext for EventContext { +impl __sdk::DbContext for EventContext { type DbView = RemoteTables; type Reducers = RemoteReducers; type SetReducerFlags = SetReducerFlags; @@ -2539,14 +3213,14 @@ impl __sdk::db_context::DbContext for EventContext { self.imp.is_active() } - fn disconnect(&self) -> spacetimedb_sdk::anyhow::Result<()> { + fn disconnect(&self) -> __anyhow::Result<()> { self.imp.disconnect() } - type SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder; + type SubscriptionBuilder = __sdk::SubscriptionBuilder; fn subscription_builder(&self) -> Self::SubscriptionBuilder { - __sdk::subscription::SubscriptionBuilder::new(&self.imp) + __sdk::SubscriptionBuilder::new(&self.imp) } fn try_identity(&self) -> Option<__sdk::Identity> { @@ -2557,11 +3231,11 @@ impl __sdk::db_context::DbContext for EventContext { } } -impl __sdk::spacetime_module::EventContext for EventContext { - fn event(&self) -> &__sdk::event::Event { +impl __sdk::EventContext for EventContext { + fn event(&self) -> &__sdk::Event { &self.event } - fn new(imp: __sdk::db_connection::DbContextImpl, event: __sdk::event::Event) -> Self { + fn new(imp: __sdk::DbContextImpl, event: __sdk::Event) -> Self { Self { db: RemoteTables { imp: imp.clone() }, reducers: RemoteReducers { imp: imp.clone() }, @@ -2575,15 +3249,15 @@ impl __sdk::spacetime_module::EventContext for EventContext { /// A handle on a subscribed query. // TODO: Document this better after implementing the new subscription API. pub struct SubscriptionHandle { - imp: __sdk::subscription::SubscriptionHandleImpl, + imp: __sdk::SubscriptionHandleImpl, } -impl __sdk::spacetime_module::InModule for SubscriptionHandle { +impl __sdk::InModule for SubscriptionHandle { type Module = RemoteModule; } -impl __sdk::spacetime_module::SubscriptionHandle for SubscriptionHandle { - fn new(imp: __sdk::subscription::SubscriptionHandleImpl) -> Self { +impl __sdk::SubscriptionHandle for SubscriptionHandle { + fn new(imp: __sdk::SubscriptionHandleImpl) -> Self { Self { imp } } } @@ -2598,7 +3272,7 @@ pub trait RemoteDbContext: DbView = RemoteTables, Reducers = RemoteReducers, SetReducerFlags = SetReducerFlags, - SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder, + SubscriptionBuilder = __sdk::SubscriptionBuilder, > { } @@ -2607,8 +3281,113 @@ impl< DbView = RemoteTables, Reducers = RemoteReducers, SetReducerFlags = SetReducerFlags, - SubscriptionBuilder = __sdk::subscription::SubscriptionBuilder, + SubscriptionBuilder = __sdk::SubscriptionBuilder, >, > RemoteDbContext for Ctx { } + +impl __sdk::SpacetimeModule for RemoteModule { + type DbConnection = DbConnection; + type EventContext = EventContext; + type Reducer = Reducer; + type DbView = RemoteTables; + type Reducers = RemoteReducers; + type SetReducerFlags = SetReducerFlags; + type DbUpdate = DbUpdate; + type SubscriptionHandle = SubscriptionHandle; + + fn register_tables(client_cache: &mut __sdk::ClientCache) { + indexed_table_table::register_table(client_cache); + indexed_table_2_table::register_table(client_cache); + large_table_table::register_table(client_cache); + one_address_table::register_table(client_cache); + one_bool_table::register_table(client_cache); + one_byte_struct_table::register_table(client_cache); + one_enum_with_payload_table::register_table(client_cache); + one_every_primitive_struct_table::register_table(client_cache); + one_every_vec_struct_table::register_table(client_cache); + one_f_32_table::register_table(client_cache); + one_f_64_table::register_table(client_cache); + one_i_128_table::register_table(client_cache); + one_i_16_table::register_table(client_cache); + one_i_256_table::register_table(client_cache); + one_i_32_table::register_table(client_cache); + one_i_64_table::register_table(client_cache); + one_i_8_table::register_table(client_cache); + one_identity_table::register_table(client_cache); + one_simple_enum_table::register_table(client_cache); + one_string_table::register_table(client_cache); + one_u_128_table::register_table(client_cache); + one_u_16_table::register_table(client_cache); + one_u_256_table::register_table(client_cache); + one_u_32_table::register_table(client_cache); + one_u_64_table::register_table(client_cache); + one_u_8_table::register_table(client_cache); + one_unit_struct_table::register_table(client_cache); + option_every_primitive_struct_table::register_table(client_cache); + option_i_32_table::register_table(client_cache); + option_identity_table::register_table(client_cache); + option_simple_enum_table::register_table(client_cache); + option_string_table::register_table(client_cache); + option_vec_option_i_32_table::register_table(client_cache); + pk_address_table::register_table(client_cache); + pk_bool_table::register_table(client_cache); + pk_i_128_table::register_table(client_cache); + pk_i_16_table::register_table(client_cache); + pk_i_256_table::register_table(client_cache); + pk_i_32_table::register_table(client_cache); + pk_i_64_table::register_table(client_cache); + pk_i_8_table::register_table(client_cache); + pk_identity_table::register_table(client_cache); + pk_string_table::register_table(client_cache); + pk_u_128_table::register_table(client_cache); + pk_u_16_table::register_table(client_cache); + pk_u_256_table::register_table(client_cache); + pk_u_32_table::register_table(client_cache); + pk_u_64_table::register_table(client_cache); + pk_u_8_table::register_table(client_cache); + scheduled_table_table::register_table(client_cache); + table_holds_table_table::register_table(client_cache); + unique_address_table::register_table(client_cache); + unique_bool_table::register_table(client_cache); + unique_i_128_table::register_table(client_cache); + unique_i_16_table::register_table(client_cache); + unique_i_256_table::register_table(client_cache); + unique_i_32_table::register_table(client_cache); + unique_i_64_table::register_table(client_cache); + unique_i_8_table::register_table(client_cache); + unique_identity_table::register_table(client_cache); + unique_string_table::register_table(client_cache); + unique_u_128_table::register_table(client_cache); + unique_u_16_table::register_table(client_cache); + unique_u_256_table::register_table(client_cache); + unique_u_32_table::register_table(client_cache); + unique_u_64_table::register_table(client_cache); + unique_u_8_table::register_table(client_cache); + vec_address_table::register_table(client_cache); + vec_bool_table::register_table(client_cache); + vec_byte_struct_table::register_table(client_cache); + vec_enum_with_payload_table::register_table(client_cache); + vec_every_primitive_struct_table::register_table(client_cache); + vec_every_vec_struct_table::register_table(client_cache); + vec_f_32_table::register_table(client_cache); + vec_f_64_table::register_table(client_cache); + vec_i_128_table::register_table(client_cache); + vec_i_16_table::register_table(client_cache); + vec_i_256_table::register_table(client_cache); + vec_i_32_table::register_table(client_cache); + vec_i_64_table::register_table(client_cache); + vec_i_8_table::register_table(client_cache); + vec_identity_table::register_table(client_cache); + vec_simple_enum_table::register_table(client_cache); + vec_string_table::register_table(client_cache); + vec_u_128_table::register_table(client_cache); + vec_u_16_table::register_table(client_cache); + vec_u_256_table::register_table(client_cache); + vec_u_32_table::register_table(client_cache); + vec_u_64_table::register_table(client_cache); + vec_u_8_table::register_table(client_cache); + vec_unit_struct_table::register_table(client_cache); + } +} diff --git a/crates/sdk/tests/test-client/src/module_bindings/no_op_succeeds_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/no_op_succeeds_reducer.rs index a73357f3506..cfe9505690c 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/no_op_succeeds_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/no_op_succeeds_reducer.rs @@ -2,21 +2,26 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct NoOpSucceeds {} +pub(super) struct NoOpSucceedsArgs {} -impl __sdk::spacetime_module::InModule for NoOpSucceeds { +impl From for super::Reducer { + fn from(args: NoOpSucceedsArgs) -> Self { + Self::NoOpSucceeds + } +} + +impl __sdk::InModule for NoOpSucceedsArgs { type Module = super::RemoteModule; } -pub struct NoOpSucceedsCallbackId(__sdk::callbacks::CallbackId); +pub struct NoOpSucceedsCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `no_op_succeeds`. @@ -47,19 +52,32 @@ pub trait no_op_succeeds { impl no_op_succeeds for super::RemoteReducers { fn no_op_succeeds(&self) -> __anyhow::Result<()> { - self.imp.call_reducer("no_op_succeeds", NoOpSucceeds {}) + self.imp.call_reducer("no_op_succeeds", NoOpSucceedsArgs {}) } fn on_no_op_succeeds( &self, mut callback: impl FnMut(&super::EventContext) + Send + 'static, ) -> NoOpSucceedsCallbackId { - NoOpSucceedsCallbackId(self.imp.on_reducer::( + NoOpSucceedsCallbackId(self.imp.on_reducer( "no_op_succeeds", - Box::new(move |ctx: &super::EventContext, args: &NoOpSucceeds| callback(ctx)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::NoOpSucceeds {}, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx) + }), )) } fn remove_on_no_op_succeeds(&self, callback: NoOpSucceedsCallbackId) { - self.imp.remove_on_reducer::("no_op_succeeds", callback.0) + self.imp.remove_on_reducer("no_op_succeeds", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_address_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_address_table.rs index 8ffe10b8b7f..0368984fe9c 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_address_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_address_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_address_type::OneAddress; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_address`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_address().on_insert(...)`. pub struct OneAddressTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneAddressTableAccess for super::RemoteTables { } } -pub struct OneAddressInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneAddressDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneAddressInsertCallbackId(__sdk::CallbackId); +pub struct OneAddressDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneAddressTableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneAddressTableHandle<'ctx> { type Row = OneAddress; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneAddressTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_address"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_address\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_address_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_address_type.rs index 3332120775f..824a4f8bafc 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_address_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_address_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneAddress { pub a: __sdk::Address, } -impl __sdk::spacetime_module::InModule for OneAddress { +impl __sdk::InModule for OneAddress { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_bool_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_bool_table.rs index 96b0df62268..0b995c83a5b 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_bool_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_bool_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_bool_type::OneBool; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_bool`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_bool().on_insert(...)`. pub struct OneBoolTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneBoolTableAccess for super::RemoteTables { } } -pub struct OneBoolInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneBoolDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneBoolInsertCallbackId(__sdk::CallbackId); +pub struct OneBoolDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneBoolTableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneBoolTableHandle<'ctx> { type Row = OneBool; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneBoolTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_bool"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_bool\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_bool_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_bool_type.rs index 6798d6189c5..b7cdb891b5d 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_bool_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_bool_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneBool { pub b: bool, } -impl __sdk::spacetime_module::InModule for OneBool { +impl __sdk::InModule for OneBool { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_byte_struct_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_byte_struct_table.rs index 0207fbb9226..34810c9f22b 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_byte_struct_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_byte_struct_table.rs @@ -4,10 +4,9 @@ #![allow(unused)] use super::byte_struct_type::ByteStruct; use super::one_byte_struct_type::OneByteStruct; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_byte_struct`. @@ -19,7 +18,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_byte_struct().on_insert(...)`. pub struct OneByteStructTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -42,10 +41,10 @@ impl OneByteStructTableAccess for super::RemoteTables { } } -pub struct OneByteStructInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneByteStructDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneByteStructInsertCallbackId(__sdk::CallbackId); +pub struct OneByteStructDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneByteStructTableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneByteStructTableHandle<'ctx> { type Row = OneByteStruct; type EventContext = super::EventContext; @@ -83,10 +82,14 @@ impl<'ctx> __sdk::table::Table for OneByteStructTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_byte_struct"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_byte_struct\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_byte_struct_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_byte_struct_type.rs index e68e93691c0..403fe9bf273 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_byte_struct_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_byte_struct_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::byte_struct_type::ByteStruct; @@ -16,6 +15,6 @@ pub struct OneByteStruct { pub s: ByteStruct, } -impl __sdk::spacetime_module::InModule for OneByteStruct { +impl __sdk::InModule for OneByteStruct { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_enum_with_payload_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_enum_with_payload_table.rs index a2e394dd423..97135d67876 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_enum_with_payload_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_enum_with_payload_table.rs @@ -4,10 +4,9 @@ #![allow(unused)] use super::enum_with_payload_type::EnumWithPayload; use super::one_enum_with_payload_type::OneEnumWithPayload; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_enum_with_payload`. @@ -19,7 +18,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_enum_with_payload().on_insert(...)`. pub struct OneEnumWithPayloadTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -42,10 +41,10 @@ impl OneEnumWithPayloadTableAccess for super::RemoteTables { } } -pub struct OneEnumWithPayloadInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneEnumWithPayloadDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneEnumWithPayloadInsertCallbackId(__sdk::CallbackId); +pub struct OneEnumWithPayloadDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneEnumWithPayloadTableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneEnumWithPayloadTableHandle<'ctx> { type Row = OneEnumWithPayload; type EventContext = super::EventContext; @@ -83,10 +82,14 @@ impl<'ctx> __sdk::table::Table for OneEnumWithPayloadTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_enum_with_payload"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_enum_with_payload\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_enum_with_payload_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_enum_with_payload_type.rs index f5f7a0f600a..fb52cb034c4 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_enum_with_payload_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_enum_with_payload_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::enum_with_payload_type::EnumWithPayload; @@ -16,6 +15,6 @@ pub struct OneEnumWithPayload { pub e: EnumWithPayload, } -impl __sdk::spacetime_module::InModule for OneEnumWithPayload { +impl __sdk::InModule for OneEnumWithPayload { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_every_primitive_struct_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_every_primitive_struct_table.rs index 5a3ad06666f..73f3f8347cb 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_every_primitive_struct_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_every_primitive_struct_table.rs @@ -4,10 +4,9 @@ #![allow(unused)] use super::every_primitive_struct_type::EveryPrimitiveStruct; use super::one_every_primitive_struct_type::OneEveryPrimitiveStruct; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_every_primitive_struct`. @@ -19,7 +18,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_every_primitive_struct().on_insert(...)`. pub struct OneEveryPrimitiveStructTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -44,10 +43,10 @@ impl OneEveryPrimitiveStructTableAccess for super::RemoteTables { } } -pub struct OneEveryPrimitiveStructInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneEveryPrimitiveStructDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneEveryPrimitiveStructInsertCallbackId(__sdk::CallbackId); +pub struct OneEveryPrimitiveStructDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneEveryPrimitiveStructTableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneEveryPrimitiveStructTableHandle<'ctx> { type Row = OneEveryPrimitiveStruct; type EventContext = super::EventContext; @@ -85,10 +84,14 @@ impl<'ctx> __sdk::table::Table for OneEveryPrimitiveStructTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_every_primitive_struct"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_every_primitive_struct\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_every_primitive_struct_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_every_primitive_struct_type.rs index c3dbfdf9fa5..4e200d92317 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_every_primitive_struct_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_every_primitive_struct_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::every_primitive_struct_type::EveryPrimitiveStruct; @@ -16,6 +15,6 @@ pub struct OneEveryPrimitiveStruct { pub s: EveryPrimitiveStruct, } -impl __sdk::spacetime_module::InModule for OneEveryPrimitiveStruct { +impl __sdk::InModule for OneEveryPrimitiveStruct { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_every_vec_struct_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_every_vec_struct_table.rs index 8d81e12c580..6996bbd3911 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_every_vec_struct_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_every_vec_struct_table.rs @@ -4,10 +4,9 @@ #![allow(unused)] use super::every_vec_struct_type::EveryVecStruct; use super::one_every_vec_struct_type::OneEveryVecStruct; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_every_vec_struct`. @@ -19,7 +18,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_every_vec_struct().on_insert(...)`. pub struct OneEveryVecStructTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -42,10 +41,10 @@ impl OneEveryVecStructTableAccess for super::RemoteTables { } } -pub struct OneEveryVecStructInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneEveryVecStructDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneEveryVecStructInsertCallbackId(__sdk::CallbackId); +pub struct OneEveryVecStructDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneEveryVecStructTableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneEveryVecStructTableHandle<'ctx> { type Row = OneEveryVecStruct; type EventContext = super::EventContext; @@ -83,10 +82,14 @@ impl<'ctx> __sdk::table::Table for OneEveryVecStructTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_every_vec_struct"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_every_vec_struct\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_every_vec_struct_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_every_vec_struct_type.rs index 6ad0856123f..dad26294de1 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_every_vec_struct_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_every_vec_struct_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::every_vec_struct_type::EveryVecStruct; @@ -16,6 +15,6 @@ pub struct OneEveryVecStruct { pub s: EveryVecStruct, } -impl __sdk::spacetime_module::InModule for OneEveryVecStruct { +impl __sdk::InModule for OneEveryVecStruct { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_f_32_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_f_32_table.rs index 26fde871750..45e3cb55443 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_f_32_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_f_32_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_f_32_type::OneF32; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_f32`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_f_32().on_insert(...)`. pub struct OneF32TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneF32TableAccess for super::RemoteTables { } } -pub struct OneF32InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneF32DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneF32InsertCallbackId(__sdk::CallbackId); +pub struct OneF32DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneF32TableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneF32TableHandle<'ctx> { type Row = OneF32; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneF32TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_f32"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_f32\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_f_32_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_f_32_type.rs index dc945881e15..e541d17e57b 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_f_32_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_f_32_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneF32 { pub f: f32, } -impl __sdk::spacetime_module::InModule for OneF32 { +impl __sdk::InModule for OneF32 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_f_64_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_f_64_table.rs index 0faedf0e2e1..74cbbad1e26 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_f_64_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_f_64_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_f_64_type::OneF64; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_f64`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_f_64().on_insert(...)`. pub struct OneF64TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneF64TableAccess for super::RemoteTables { } } -pub struct OneF64InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneF64DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneF64InsertCallbackId(__sdk::CallbackId); +pub struct OneF64DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneF64TableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneF64TableHandle<'ctx> { type Row = OneF64; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneF64TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_f64"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_f64\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_f_64_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_f_64_type.rs index 3895270f3dc..3de053009cb 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_f_64_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_f_64_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneF64 { pub f: f64, } -impl __sdk::spacetime_module::InModule for OneF64 { +impl __sdk::InModule for OneF64 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_i_128_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_i_128_table.rs index c2df488aab7..b2c5a89fa98 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_i_128_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_i_128_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_i_128_type::OneI128; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_i128`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_i_128().on_insert(...)`. pub struct OneI128TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneI128TableAccess for super::RemoteTables { } } -pub struct OneI128InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneI128DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneI128InsertCallbackId(__sdk::CallbackId); +pub struct OneI128DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneI128TableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneI128TableHandle<'ctx> { type Row = OneI128; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneI128TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_i128"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_i128\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_i_128_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_i_128_type.rs index e2ce8352e1a..efd1df1ec44 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_i_128_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_i_128_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneI128 { pub n: i128, } -impl __sdk::spacetime_module::InModule for OneI128 { +impl __sdk::InModule for OneI128 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_i_16_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_i_16_table.rs index 97bcc8b8718..b8a28ceaf13 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_i_16_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_i_16_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_i_16_type::OneI16; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_i16`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_i_16().on_insert(...)`. pub struct OneI16TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneI16TableAccess for super::RemoteTables { } } -pub struct OneI16InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneI16DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneI16InsertCallbackId(__sdk::CallbackId); +pub struct OneI16DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneI16TableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneI16TableHandle<'ctx> { type Row = OneI16; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneI16TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_i16"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_i16\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_i_16_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_i_16_type.rs index e35520056ca..ceb8878efcb 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_i_16_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_i_16_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneI16 { pub n: i16, } -impl __sdk::spacetime_module::InModule for OneI16 { +impl __sdk::InModule for OneI16 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_i_256_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_i_256_table.rs index d6324fa9925..c2c218dbc66 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_i_256_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_i_256_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_i_256_type::OneI256; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_i256`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_i_256().on_insert(...)`. pub struct OneI256TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneI256TableAccess for super::RemoteTables { } } -pub struct OneI256InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneI256DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneI256InsertCallbackId(__sdk::CallbackId); +pub struct OneI256DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneI256TableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneI256TableHandle<'ctx> { type Row = OneI256; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneI256TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_i256"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_i256\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_i_256_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_i_256_type.rs index 8c6807b87de..20563b4028f 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_i_256_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_i_256_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneI256 { pub n: __sats::i256, } -impl __sdk::spacetime_module::InModule for OneI256 { +impl __sdk::InModule for OneI256 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_i_32_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_i_32_table.rs index fd9faa963b6..7085aef24e2 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_i_32_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_i_32_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_i_32_type::OneI32; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_i32`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_i_32().on_insert(...)`. pub struct OneI32TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneI32TableAccess for super::RemoteTables { } } -pub struct OneI32InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneI32DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneI32InsertCallbackId(__sdk::CallbackId); +pub struct OneI32DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneI32TableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneI32TableHandle<'ctx> { type Row = OneI32; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneI32TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_i32"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_i32\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_i_32_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_i_32_type.rs index 2aaf8b89ec9..859e35c2143 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_i_32_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_i_32_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneI32 { pub n: i32, } -impl __sdk::spacetime_module::InModule for OneI32 { +impl __sdk::InModule for OneI32 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_i_64_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_i_64_table.rs index 48848e16067..472a0839c6a 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_i_64_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_i_64_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_i_64_type::OneI64; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_i64`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_i_64().on_insert(...)`. pub struct OneI64TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneI64TableAccess for super::RemoteTables { } } -pub struct OneI64InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneI64DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneI64InsertCallbackId(__sdk::CallbackId); +pub struct OneI64DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneI64TableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneI64TableHandle<'ctx> { type Row = OneI64; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneI64TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_i64"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_i64\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_i_64_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_i_64_type.rs index 20ad1bf19c9..3599e9043d6 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_i_64_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_i_64_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneI64 { pub n: i64, } -impl __sdk::spacetime_module::InModule for OneI64 { +impl __sdk::InModule for OneI64 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_i_8_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_i_8_table.rs index 5cf171ebeee..406bdd76194 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_i_8_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_i_8_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_i_8_type::OneI8; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_i8`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_i_8().on_insert(...)`. pub struct OneI8TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneI8TableAccess for super::RemoteTables { } } -pub struct OneI8InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneI8DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneI8InsertCallbackId(__sdk::CallbackId); +pub struct OneI8DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneI8TableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneI8TableHandle<'ctx> { type Row = OneI8; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneI8TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_i8"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_i8\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_i_8_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_i_8_type.rs index 885690c6181..416521ff6c2 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_i_8_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_i_8_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneI8 { pub n: i8, } -impl __sdk::spacetime_module::InModule for OneI8 { +impl __sdk::InModule for OneI8 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_identity_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_identity_table.rs index ebc48489897..03db879a32c 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_identity_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_identity_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_identity_type::OneIdentity; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_identity`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_identity().on_insert(...)`. pub struct OneIdentityTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneIdentityTableAccess for super::RemoteTables { } } -pub struct OneIdentityInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneIdentityDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneIdentityInsertCallbackId(__sdk::CallbackId); +pub struct OneIdentityDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneIdentityTableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneIdentityTableHandle<'ctx> { type Row = OneIdentity; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneIdentityTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_identity"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_identity\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_identity_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_identity_type.rs index 4d2d0b66c4b..36a0b355e12 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_identity_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_identity_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneIdentity { pub i: __sdk::Identity, } -impl __sdk::spacetime_module::InModule for OneIdentity { +impl __sdk::InModule for OneIdentity { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_simple_enum_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_simple_enum_table.rs index 0bd9641621f..5f171e8075d 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_simple_enum_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_simple_enum_table.rs @@ -4,10 +4,9 @@ #![allow(unused)] use super::one_simple_enum_type::OneSimpleEnum; use super::simple_enum_type::SimpleEnum; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_simple_enum`. @@ -19,7 +18,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_simple_enum().on_insert(...)`. pub struct OneSimpleEnumTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -42,10 +41,10 @@ impl OneSimpleEnumTableAccess for super::RemoteTables { } } -pub struct OneSimpleEnumInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneSimpleEnumDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneSimpleEnumInsertCallbackId(__sdk::CallbackId); +pub struct OneSimpleEnumDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneSimpleEnumTableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneSimpleEnumTableHandle<'ctx> { type Row = OneSimpleEnum; type EventContext = super::EventContext; @@ -83,10 +82,14 @@ impl<'ctx> __sdk::table::Table for OneSimpleEnumTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_simple_enum"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_simple_enum\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_simple_enum_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_simple_enum_type.rs index 08432d4faab..6edde9f29c5 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_simple_enum_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_simple_enum_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::simple_enum_type::SimpleEnum; @@ -16,6 +15,6 @@ pub struct OneSimpleEnum { pub e: SimpleEnum, } -impl __sdk::spacetime_module::InModule for OneSimpleEnum { +impl __sdk::InModule for OneSimpleEnum { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_string_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_string_table.rs index 2e814b11fb0..90e6b5399ad 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_string_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_string_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_string_type::OneString; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_string`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_string().on_insert(...)`. pub struct OneStringTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneStringTableAccess for super::RemoteTables { } } -pub struct OneStringInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneStringDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneStringInsertCallbackId(__sdk::CallbackId); +pub struct OneStringDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneStringTableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneStringTableHandle<'ctx> { type Row = OneString; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneStringTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_string"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_string\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_string_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_string_type.rs index 2addf180710..e9d16eaf4e9 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_string_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_string_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneString { pub s: String, } -impl __sdk::spacetime_module::InModule for OneString { +impl __sdk::InModule for OneString { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_u_128_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_u_128_table.rs index fa297175ef3..e8dc6ff7f66 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_u_128_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_u_128_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_u_128_type::OneU128; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_u128`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_u_128().on_insert(...)`. pub struct OneU128TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneU128TableAccess for super::RemoteTables { } } -pub struct OneU128InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneU128DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneU128InsertCallbackId(__sdk::CallbackId); +pub struct OneU128DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneU128TableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneU128TableHandle<'ctx> { type Row = OneU128; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneU128TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_u128"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_u128\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_u_128_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_u_128_type.rs index 2c72d6969bc..34f07342045 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_u_128_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_u_128_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneU128 { pub n: u128, } -impl __sdk::spacetime_module::InModule for OneU128 { +impl __sdk::InModule for OneU128 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_u_16_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_u_16_table.rs index 0837ef2464b..85540e76404 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_u_16_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_u_16_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_u_16_type::OneU16; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_u16`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_u_16().on_insert(...)`. pub struct OneU16TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneU16TableAccess for super::RemoteTables { } } -pub struct OneU16InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneU16DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneU16InsertCallbackId(__sdk::CallbackId); +pub struct OneU16DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneU16TableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneU16TableHandle<'ctx> { type Row = OneU16; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneU16TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_u16"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_u16\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_u_16_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_u_16_type.rs index 4e6b998b1b9..b128c9c92e1 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_u_16_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_u_16_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneU16 { pub n: u16, } -impl __sdk::spacetime_module::InModule for OneU16 { +impl __sdk::InModule for OneU16 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_u_256_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_u_256_table.rs index 6e52f5391c3..70fa10ead5e 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_u_256_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_u_256_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_u_256_type::OneU256; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_u256`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_u_256().on_insert(...)`. pub struct OneU256TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneU256TableAccess for super::RemoteTables { } } -pub struct OneU256InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneU256DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneU256InsertCallbackId(__sdk::CallbackId); +pub struct OneU256DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneU256TableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneU256TableHandle<'ctx> { type Row = OneU256; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneU256TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_u256"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_u256\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_u_256_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_u_256_type.rs index 2b01c219a67..280ff304b76 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_u_256_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_u_256_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneU256 { pub n: __sats::u256, } -impl __sdk::spacetime_module::InModule for OneU256 { +impl __sdk::InModule for OneU256 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_u_32_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_u_32_table.rs index 9f52581069e..bb8b7b18b99 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_u_32_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_u_32_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_u_32_type::OneU32; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_u32`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_u_32().on_insert(...)`. pub struct OneU32TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneU32TableAccess for super::RemoteTables { } } -pub struct OneU32InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneU32DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneU32InsertCallbackId(__sdk::CallbackId); +pub struct OneU32DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneU32TableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneU32TableHandle<'ctx> { type Row = OneU32; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneU32TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_u32"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_u32\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_u_32_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_u_32_type.rs index b632883db39..e8373dcd35b 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_u_32_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_u_32_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneU32 { pub n: u32, } -impl __sdk::spacetime_module::InModule for OneU32 { +impl __sdk::InModule for OneU32 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_u_64_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_u_64_table.rs index 6e6af7251f9..2f33488ca38 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_u_64_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_u_64_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_u_64_type::OneU64; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_u64`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_u_64().on_insert(...)`. pub struct OneU64TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneU64TableAccess for super::RemoteTables { } } -pub struct OneU64InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneU64DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneU64InsertCallbackId(__sdk::CallbackId); +pub struct OneU64DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneU64TableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneU64TableHandle<'ctx> { type Row = OneU64; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneU64TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_u64"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_u64\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_u_64_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_u_64_type.rs index e1a8994d92d..37414210738 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_u_64_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_u_64_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneU64 { pub n: u64, } -impl __sdk::spacetime_module::InModule for OneU64 { +impl __sdk::InModule for OneU64 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_u_8_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_u_8_table.rs index ef4b642c361..a179b7a2d06 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_u_8_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_u_8_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::one_u_8_type::OneU8; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_u8`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_u_8().on_insert(...)`. pub struct OneU8TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OneU8TableAccess for super::RemoteTables { } } -pub struct OneU8InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneU8DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneU8InsertCallbackId(__sdk::CallbackId); +pub struct OneU8DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneU8TableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneU8TableHandle<'ctx> { type Row = OneU8; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OneU8TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_u8"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_u8\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_u_8_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_u_8_type.rs index 0729671e0c5..a5ff23a658a 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_u_8_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_u_8_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OneU8 { pub n: u8, } -impl __sdk::spacetime_module::InModule for OneU8 { +impl __sdk::InModule for OneU8 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_unit_struct_table.rs b/crates/sdk/tests/test-client/src/module_bindings/one_unit_struct_table.rs index 8fb41e77296..25c2b0ec330 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_unit_struct_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_unit_struct_table.rs @@ -4,10 +4,9 @@ #![allow(unused)] use super::one_unit_struct_type::OneUnitStruct; use super::unit_struct_type::UnitStruct; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `one_unit_struct`. @@ -19,7 +18,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.one_unit_struct().on_insert(...)`. pub struct OneUnitStructTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -42,10 +41,10 @@ impl OneUnitStructTableAccess for super::RemoteTables { } } -pub struct OneUnitStructInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OneUnitStructDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OneUnitStructInsertCallbackId(__sdk::CallbackId); +pub struct OneUnitStructDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OneUnitStructTableHandle<'ctx> { +impl<'ctx> __sdk::Table for OneUnitStructTableHandle<'ctx> { type Row = OneUnitStruct; type EventContext = super::EventContext; @@ -83,10 +82,14 @@ impl<'ctx> __sdk::table::Table for OneUnitStructTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("one_unit_struct"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"one_unit_struct\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/one_unit_struct_type.rs b/crates/sdk/tests/test-client/src/module_bindings/one_unit_struct_type.rs index d2b200413e3..04b6d4668fc 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/one_unit_struct_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/one_unit_struct_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::unit_struct_type::UnitStruct; @@ -16,6 +15,6 @@ pub struct OneUnitStruct { pub s: UnitStruct, } -impl __sdk::spacetime_module::InModule for OneUnitStruct { +impl __sdk::InModule for OneUnitStruct { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/option_every_primitive_struct_table.rs b/crates/sdk/tests/test-client/src/module_bindings/option_every_primitive_struct_table.rs index 5c84712ea82..63d5e69f794 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/option_every_primitive_struct_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/option_every_primitive_struct_table.rs @@ -4,10 +4,9 @@ #![allow(unused)] use super::every_primitive_struct_type::EveryPrimitiveStruct; use super::option_every_primitive_struct_type::OptionEveryPrimitiveStruct; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `option_every_primitive_struct`. @@ -19,7 +18,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.option_every_primitive_struct().on_insert(...)`. pub struct OptionEveryPrimitiveStructTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -44,10 +43,10 @@ impl OptionEveryPrimitiveStructTableAccess for super::RemoteTables { } } -pub struct OptionEveryPrimitiveStructInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OptionEveryPrimitiveStructDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OptionEveryPrimitiveStructInsertCallbackId(__sdk::CallbackId); +pub struct OptionEveryPrimitiveStructDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OptionEveryPrimitiveStructTableHandle<'ctx> { +impl<'ctx> __sdk::Table for OptionEveryPrimitiveStructTableHandle<'ctx> { type Row = OptionEveryPrimitiveStruct; type EventContext = super::EventContext; @@ -85,10 +84,14 @@ impl<'ctx> __sdk::table::Table for OptionEveryPrimitiveStructTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("option_every_primitive_struct"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"option_every_primitive_struct\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/option_every_primitive_struct_type.rs b/crates/sdk/tests/test-client/src/module_bindings/option_every_primitive_struct_type.rs index 975c4a938b5..882a812b784 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/option_every_primitive_struct_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/option_every_primitive_struct_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::every_primitive_struct_type::EveryPrimitiveStruct; @@ -16,6 +15,6 @@ pub struct OptionEveryPrimitiveStruct { pub s: Option, } -impl __sdk::spacetime_module::InModule for OptionEveryPrimitiveStruct { +impl __sdk::InModule for OptionEveryPrimitiveStruct { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/option_i_32_table.rs b/crates/sdk/tests/test-client/src/module_bindings/option_i_32_table.rs index 12124867e24..876c1b2ce45 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/option_i_32_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/option_i_32_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::option_i_32_type::OptionI32; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `option_i32`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.option_i_32().on_insert(...)`. pub struct OptionI32TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OptionI32TableAccess for super::RemoteTables { } } -pub struct OptionI32InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OptionI32DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OptionI32InsertCallbackId(__sdk::CallbackId); +pub struct OptionI32DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OptionI32TableHandle<'ctx> { +impl<'ctx> __sdk::Table for OptionI32TableHandle<'ctx> { type Row = OptionI32; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OptionI32TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("option_i32"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"option_i32\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/option_i_32_type.rs b/crates/sdk/tests/test-client/src/module_bindings/option_i_32_type.rs index 4e7837a4439..ec6d8fa3a9b 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/option_i_32_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/option_i_32_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OptionI32 { pub n: Option, } -impl __sdk::spacetime_module::InModule for OptionI32 { +impl __sdk::InModule for OptionI32 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/option_identity_table.rs b/crates/sdk/tests/test-client/src/module_bindings/option_identity_table.rs index 2647083952a..adb94e37dca 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/option_identity_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/option_identity_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::option_identity_type::OptionIdentity; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `option_identity`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.option_identity().on_insert(...)`. pub struct OptionIdentityTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OptionIdentityTableAccess for super::RemoteTables { } } -pub struct OptionIdentityInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OptionIdentityDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OptionIdentityInsertCallbackId(__sdk::CallbackId); +pub struct OptionIdentityDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OptionIdentityTableHandle<'ctx> { +impl<'ctx> __sdk::Table for OptionIdentityTableHandle<'ctx> { type Row = OptionIdentity; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OptionIdentityTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("option_identity"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"option_identity\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/option_identity_type.rs b/crates/sdk/tests/test-client/src/module_bindings/option_identity_type.rs index 93856ee522f..9b6c0287936 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/option_identity_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/option_identity_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OptionIdentity { pub i: Option<__sdk::Identity>, } -impl __sdk::spacetime_module::InModule for OptionIdentity { +impl __sdk::InModule for OptionIdentity { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/option_simple_enum_table.rs b/crates/sdk/tests/test-client/src/module_bindings/option_simple_enum_table.rs index 73a78ff2826..d8a0fe2da24 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/option_simple_enum_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/option_simple_enum_table.rs @@ -4,10 +4,9 @@ #![allow(unused)] use super::option_simple_enum_type::OptionSimpleEnum; use super::simple_enum_type::SimpleEnum; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `option_simple_enum`. @@ -19,7 +18,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.option_simple_enum().on_insert(...)`. pub struct OptionSimpleEnumTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -42,10 +41,10 @@ impl OptionSimpleEnumTableAccess for super::RemoteTables { } } -pub struct OptionSimpleEnumInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OptionSimpleEnumDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OptionSimpleEnumInsertCallbackId(__sdk::CallbackId); +pub struct OptionSimpleEnumDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OptionSimpleEnumTableHandle<'ctx> { +impl<'ctx> __sdk::Table for OptionSimpleEnumTableHandle<'ctx> { type Row = OptionSimpleEnum; type EventContext = super::EventContext; @@ -83,10 +82,14 @@ impl<'ctx> __sdk::table::Table for OptionSimpleEnumTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("option_simple_enum"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"option_simple_enum\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/option_simple_enum_type.rs b/crates/sdk/tests/test-client/src/module_bindings/option_simple_enum_type.rs index 48b64076a75..57c6696cda7 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/option_simple_enum_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/option_simple_enum_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::simple_enum_type::SimpleEnum; @@ -16,6 +15,6 @@ pub struct OptionSimpleEnum { pub e: Option, } -impl __sdk::spacetime_module::InModule for OptionSimpleEnum { +impl __sdk::InModule for OptionSimpleEnum { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/option_string_table.rs b/crates/sdk/tests/test-client/src/module_bindings/option_string_table.rs index 836b50224df..f4efbb74046 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/option_string_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/option_string_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::option_string_type::OptionString; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `option_string`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.option_string().on_insert(...)`. pub struct OptionStringTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OptionStringTableAccess for super::RemoteTables { } } -pub struct OptionStringInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OptionStringDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OptionStringInsertCallbackId(__sdk::CallbackId); +pub struct OptionStringDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OptionStringTableHandle<'ctx> { +impl<'ctx> __sdk::Table for OptionStringTableHandle<'ctx> { type Row = OptionString; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OptionStringTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("option_string"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"option_string\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/option_string_type.rs b/crates/sdk/tests/test-client/src/module_bindings/option_string_type.rs index c045acd3312..dc7642e83ac 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/option_string_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/option_string_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OptionString { pub s: Option, } -impl __sdk::spacetime_module::InModule for OptionString { +impl __sdk::InModule for OptionString { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/option_vec_option_i_32_table.rs b/crates/sdk/tests/test-client/src/module_bindings/option_vec_option_i_32_table.rs index 9dd2783ebab..b4098b47631 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/option_vec_option_i_32_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/option_vec_option_i_32_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::option_vec_option_i_32_type::OptionVecOptionI32; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `option_vec_option_i32`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.option_vec_option_i_32().on_insert(...)`. pub struct OptionVecOptionI32TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl OptionVecOptionI32TableAccess for super::RemoteTables { } } -pub struct OptionVecOptionI32InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct OptionVecOptionI32DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct OptionVecOptionI32InsertCallbackId(__sdk::CallbackId); +pub struct OptionVecOptionI32DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for OptionVecOptionI32TableHandle<'ctx> { +impl<'ctx> __sdk::Table for OptionVecOptionI32TableHandle<'ctx> { type Row = OptionVecOptionI32; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for OptionVecOptionI32TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("option_vec_option_i32"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"option_vec_option_i32\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/option_vec_option_i_32_type.rs b/crates/sdk/tests/test-client/src/module_bindings/option_vec_option_i_32_type.rs index 3c6d367388d..a0f18e99811 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/option_vec_option_i_32_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/option_vec_option_i_32_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct OptionVecOptionI32 { pub v: Option>>, } -impl __sdk::spacetime_module::InModule for OptionVecOptionI32 { +impl __sdk::InModule for OptionVecOptionI32 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_address_table.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_address_table.rs index 7fb6c2fa765..e5d800c27f9 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_address_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_address_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::pk_address_type::PkAddress; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `pk_address`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.pk_address().on_insert(...)`. pub struct PkAddressTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl PkAddressTableAccess for super::RemoteTables { } } -pub struct PkAddressInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkAddressDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkAddressInsertCallbackId(__sdk::CallbackId); +pub struct PkAddressDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkAddressTableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkAddressTableHandle<'ctx> { type Row = PkAddress; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for PkAddressTableHandle<'ctx> { } } -pub struct PkAddressUpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("pk_address"); + _table.add_unique_constraint::<__sdk::Address>("a", |row| &row.a); +} +pub struct PkAddressUpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkAddressTableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for PkAddressTableHandle<'ctx> { type UpdateCallbackId = PkAddressUpdateCallbackId; fn on_update( @@ -102,12 +106,9 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkAddressTableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::<__sdk::Address>( - raw_updates, - |row: &PkAddress| &row.a, - ) - .context("Failed to parse table update for table \"pk_address\"") +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::<__sdk::Address>(raw_updates, |row: &PkAddress| &row.a) + .context("Failed to parse table update for table \"pk_address\"") } /// Access to the `a` unique index on the table `pk_address`, @@ -118,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_address().a().find(...)`. pub struct PkAddressAUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -126,7 +127,7 @@ impl<'ctx> PkAddressTableHandle<'ctx> { /// Get a handle on the `a` unique index on the table `pk_address`. pub fn a(&self) -> PkAddressAUnique<'ctx> { PkAddressAUnique { - imp: self.imp.get_unique_constraint::<__sdk::Address>("a", |row| &row.a), + imp: self.imp.get_unique_constraint::<__sdk::Address>("a"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_address_type.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_address_type.rs index e4f8fb01516..fe7fcd5611a 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_address_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_address_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct PkAddress { pub data: i32, } -impl __sdk::spacetime_module::InModule for PkAddress { +impl __sdk::InModule for PkAddress { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_bool_table.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_bool_table.rs index dcc9e768682..3afec905209 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_bool_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_bool_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::pk_bool_type::PkBool; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `pk_bool`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.pk_bool().on_insert(...)`. pub struct PkBoolTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl PkBoolTableAccess for super::RemoteTables { } } -pub struct PkBoolInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkBoolDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkBoolInsertCallbackId(__sdk::CallbackId); +pub struct PkBoolDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkBoolTableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkBoolTableHandle<'ctx> { type Row = PkBool; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for PkBoolTableHandle<'ctx> { } } -pub struct PkBoolUpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("pk_bool"); + _table.add_unique_constraint::("b", |row| &row.b); +} +pub struct PkBoolUpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkBoolTableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for PkBoolTableHandle<'ctx> { type UpdateCallbackId = PkBoolUpdateCallbackId; fn on_update( @@ -102,11 +106,9 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkBoolTableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkBool| { - &row.b - }) - .context("Failed to parse table update for table \"pk_bool\"") +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkBool| &row.b) + .context("Failed to parse table update for table \"pk_bool\"") } /// Access to the `b` unique index on the table `pk_bool`, @@ -117,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_bool().b().find(...)`. pub struct PkBoolBUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -125,7 +127,7 @@ impl<'ctx> PkBoolTableHandle<'ctx> { /// Get a handle on the `b` unique index on the table `pk_bool`. pub fn b(&self) -> PkBoolBUnique<'ctx> { PkBoolBUnique { - imp: self.imp.get_unique_constraint::("b", |row| &row.b), + imp: self.imp.get_unique_constraint::("b"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_bool_type.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_bool_type.rs index 323168ffd4f..aa5f7caf6be 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_bool_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_bool_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct PkBool { pub data: i32, } -impl __sdk::spacetime_module::InModule for PkBool { +impl __sdk::InModule for PkBool { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_i_128_table.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_i_128_table.rs index 8671f277b40..ddbd96bc399 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_i_128_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_i_128_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::pk_i_128_type::PkI128; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `pk_i128`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.pk_i_128().on_insert(...)`. pub struct PkI128TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl PkI128TableAccess for super::RemoteTables { } } -pub struct PkI128InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkI128DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkI128InsertCallbackId(__sdk::CallbackId); +pub struct PkI128DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkI128TableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkI128TableHandle<'ctx> { type Row = PkI128; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for PkI128TableHandle<'ctx> { } } -pub struct PkI128UpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("pk_i128"); + _table.add_unique_constraint::("n", |row| &row.n); +} +pub struct PkI128UpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkI128TableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for PkI128TableHandle<'ctx> { type UpdateCallbackId = PkI128UpdateCallbackId; fn on_update( @@ -102,11 +106,9 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkI128TableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkI128| { - &row.n - }) - .context("Failed to parse table update for table \"pk_i128\"") +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkI128| &row.n) + .context("Failed to parse table update for table \"pk_i128\"") } /// Access to the `n` unique index on the table `pk_i128`, @@ -117,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_i_128().n().find(...)`. pub struct PkI128NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -125,7 +127,7 @@ impl<'ctx> PkI128TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `pk_i128`. pub fn n(&self) -> PkI128NUnique<'ctx> { PkI128NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_i_128_type.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_i_128_type.rs index 9e98b1aaf91..d1c9ee0cc04 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_i_128_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_i_128_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct PkI128 { pub data: i32, } -impl __sdk::spacetime_module::InModule for PkI128 { +impl __sdk::InModule for PkI128 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_i_16_table.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_i_16_table.rs index 2ceadb322bd..053ee8ffa23 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_i_16_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_i_16_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::pk_i_16_type::PkI16; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `pk_i16`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.pk_i_16().on_insert(...)`. pub struct PkI16TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl PkI16TableAccess for super::RemoteTables { } } -pub struct PkI16InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkI16DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkI16InsertCallbackId(__sdk::CallbackId); +pub struct PkI16DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkI16TableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkI16TableHandle<'ctx> { type Row = PkI16; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for PkI16TableHandle<'ctx> { } } -pub struct PkI16UpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("pk_i16"); + _table.add_unique_constraint::("n", |row| &row.n); +} +pub struct PkI16UpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkI16TableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for PkI16TableHandle<'ctx> { type UpdateCallbackId = PkI16UpdateCallbackId; fn on_update( @@ -102,8 +106,8 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkI16TableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkI16| &row.n) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkI16| &row.n) .context("Failed to parse table update for table \"pk_i16\"") } @@ -115,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_i_16().n().find(...)`. pub struct PkI16NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -123,7 +127,7 @@ impl<'ctx> PkI16TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `pk_i16`. pub fn n(&self) -> PkI16NUnique<'ctx> { PkI16NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_i_16_type.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_i_16_type.rs index c98ccd3ee1d..80b4d664be3 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_i_16_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_i_16_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct PkI16 { pub data: i32, } -impl __sdk::spacetime_module::InModule for PkI16 { +impl __sdk::InModule for PkI16 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_i_256_table.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_i_256_table.rs index ea6dbdf16b4..2db2b0a3915 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_i_256_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_i_256_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::pk_i_256_type::PkI256; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `pk_i256`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.pk_i_256().on_insert(...)`. pub struct PkI256TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl PkI256TableAccess for super::RemoteTables { } } -pub struct PkI256InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkI256DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkI256InsertCallbackId(__sdk::CallbackId); +pub struct PkI256DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkI256TableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkI256TableHandle<'ctx> { type Row = PkI256; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for PkI256TableHandle<'ctx> { } } -pub struct PkI256UpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("pk_i256"); + _table.add_unique_constraint::<__sats::i256>("n", |row| &row.n); +} +pub struct PkI256UpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkI256TableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for PkI256TableHandle<'ctx> { type UpdateCallbackId = PkI256UpdateCallbackId; fn on_update( @@ -102,12 +106,9 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkI256TableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::<__sats::i256>( - raw_updates, - |row: &PkI256| &row.n, - ) - .context("Failed to parse table update for table \"pk_i256\"") +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::<__sats::i256>(raw_updates, |row: &PkI256| &row.n) + .context("Failed to parse table update for table \"pk_i256\"") } /// Access to the `n` unique index on the table `pk_i256`, @@ -118,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_i_256().n().find(...)`. pub struct PkI256NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -126,7 +127,7 @@ impl<'ctx> PkI256TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `pk_i256`. pub fn n(&self) -> PkI256NUnique<'ctx> { PkI256NUnique { - imp: self.imp.get_unique_constraint::<__sats::i256>("n", |row| &row.n), + imp: self.imp.get_unique_constraint::<__sats::i256>("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_i_256_type.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_i_256_type.rs index ae9cf60f823..fdb75e2cd43 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_i_256_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_i_256_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct PkI256 { pub data: i32, } -impl __sdk::spacetime_module::InModule for PkI256 { +impl __sdk::InModule for PkI256 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_i_32_table.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_i_32_table.rs index 51895754ca8..1c282872459 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_i_32_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_i_32_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::pk_i_32_type::PkI32; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `pk_i32`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.pk_i_32().on_insert(...)`. pub struct PkI32TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl PkI32TableAccess for super::RemoteTables { } } -pub struct PkI32InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkI32DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkI32InsertCallbackId(__sdk::CallbackId); +pub struct PkI32DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkI32TableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkI32TableHandle<'ctx> { type Row = PkI32; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for PkI32TableHandle<'ctx> { } } -pub struct PkI32UpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("pk_i32"); + _table.add_unique_constraint::("n", |row| &row.n); +} +pub struct PkI32UpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkI32TableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for PkI32TableHandle<'ctx> { type UpdateCallbackId = PkI32UpdateCallbackId; fn on_update( @@ -102,8 +106,8 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkI32TableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkI32| &row.n) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkI32| &row.n) .context("Failed to parse table update for table \"pk_i32\"") } @@ -115,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_i_32().n().find(...)`. pub struct PkI32NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -123,7 +127,7 @@ impl<'ctx> PkI32TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `pk_i32`. pub fn n(&self) -> PkI32NUnique<'ctx> { PkI32NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_i_32_type.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_i_32_type.rs index ab13d9070d1..f9486e66cbd 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_i_32_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_i_32_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct PkI32 { pub data: i32, } -impl __sdk::spacetime_module::InModule for PkI32 { +impl __sdk::InModule for PkI32 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_i_64_table.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_i_64_table.rs index f7ab21b7098..46f31da9ae4 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_i_64_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_i_64_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::pk_i_64_type::PkI64; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `pk_i64`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.pk_i_64().on_insert(...)`. pub struct PkI64TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl PkI64TableAccess for super::RemoteTables { } } -pub struct PkI64InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkI64DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkI64InsertCallbackId(__sdk::CallbackId); +pub struct PkI64DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkI64TableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkI64TableHandle<'ctx> { type Row = PkI64; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for PkI64TableHandle<'ctx> { } } -pub struct PkI64UpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("pk_i64"); + _table.add_unique_constraint::("n", |row| &row.n); +} +pub struct PkI64UpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkI64TableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for PkI64TableHandle<'ctx> { type UpdateCallbackId = PkI64UpdateCallbackId; fn on_update( @@ -102,8 +106,8 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkI64TableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkI64| &row.n) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkI64| &row.n) .context("Failed to parse table update for table \"pk_i64\"") } @@ -115,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_i_64().n().find(...)`. pub struct PkI64NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -123,7 +127,7 @@ impl<'ctx> PkI64TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `pk_i64`. pub fn n(&self) -> PkI64NUnique<'ctx> { PkI64NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_i_64_type.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_i_64_type.rs index de0ec043165..6ef7b62028f 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_i_64_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_i_64_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct PkI64 { pub data: i32, } -impl __sdk::spacetime_module::InModule for PkI64 { +impl __sdk::InModule for PkI64 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_i_8_table.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_i_8_table.rs index 691e56d7d1d..b8e5e8b1eed 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_i_8_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_i_8_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::pk_i_8_type::PkI8; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `pk_i8`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.pk_i_8().on_insert(...)`. pub struct PkI8TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl PkI8TableAccess for super::RemoteTables { } } -pub struct PkI8InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkI8DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkI8InsertCallbackId(__sdk::CallbackId); +pub struct PkI8DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkI8TableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkI8TableHandle<'ctx> { type Row = PkI8; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for PkI8TableHandle<'ctx> { } } -pub struct PkI8UpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("pk_i8"); + _table.add_unique_constraint::("n", |row| &row.n); +} +pub struct PkI8UpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkI8TableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for PkI8TableHandle<'ctx> { type UpdateCallbackId = PkI8UpdateCallbackId; fn on_update( @@ -102,8 +106,8 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkI8TableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkI8| &row.n) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkI8| &row.n) .context("Failed to parse table update for table \"pk_i8\"") } @@ -115,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_i_8().n().find(...)`. pub struct PkI8NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -123,7 +127,7 @@ impl<'ctx> PkI8TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `pk_i8`. pub fn n(&self) -> PkI8NUnique<'ctx> { PkI8NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_i_8_type.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_i_8_type.rs index d1c9083a7e4..49b1dee632d 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_i_8_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_i_8_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct PkI8 { pub data: i32, } -impl __sdk::spacetime_module::InModule for PkI8 { +impl __sdk::InModule for PkI8 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_identity_table.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_identity_table.rs index a25fe782ad6..e83e6045767 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_identity_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_identity_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::pk_identity_type::PkIdentity; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `pk_identity`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.pk_identity().on_insert(...)`. pub struct PkIdentityTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl PkIdentityTableAccess for super::RemoteTables { } } -pub struct PkIdentityInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkIdentityDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkIdentityInsertCallbackId(__sdk::CallbackId); +pub struct PkIdentityDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkIdentityTableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkIdentityTableHandle<'ctx> { type Row = PkIdentity; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for PkIdentityTableHandle<'ctx> { } } -pub struct PkIdentityUpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("pk_identity"); + _table.add_unique_constraint::<__sdk::Identity>("i", |row| &row.i); +} +pub struct PkIdentityUpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkIdentityTableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for PkIdentityTableHandle<'ctx> { type UpdateCallbackId = PkIdentityUpdateCallbackId; fn on_update( @@ -102,12 +106,9 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkIdentityTableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::<__sdk::Identity>( - raw_updates, - |row: &PkIdentity| &row.i, - ) - .context("Failed to parse table update for table \"pk_identity\"") +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::<__sdk::Identity>(raw_updates, |row: &PkIdentity| &row.i) + .context("Failed to parse table update for table \"pk_identity\"") } /// Access to the `i` unique index on the table `pk_identity`, @@ -118,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_identity().i().find(...)`. pub struct PkIdentityIUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -126,7 +127,7 @@ impl<'ctx> PkIdentityTableHandle<'ctx> { /// Get a handle on the `i` unique index on the table `pk_identity`. pub fn i(&self) -> PkIdentityIUnique<'ctx> { PkIdentityIUnique { - imp: self.imp.get_unique_constraint::<__sdk::Identity>("i", |row| &row.i), + imp: self.imp.get_unique_constraint::<__sdk::Identity>("i"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_identity_type.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_identity_type.rs index 4c639e4e913..c513455c7b6 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_identity_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_identity_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct PkIdentity { pub data: i32, } -impl __sdk::spacetime_module::InModule for PkIdentity { +impl __sdk::InModule for PkIdentity { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_string_table.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_string_table.rs index 91f9cc7f2d7..987ef9d41ae 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_string_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_string_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::pk_string_type::PkString; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `pk_string`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.pk_string().on_insert(...)`. pub struct PkStringTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl PkStringTableAccess for super::RemoteTables { } } -pub struct PkStringInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkStringDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkStringInsertCallbackId(__sdk::CallbackId); +pub struct PkStringDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkStringTableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkStringTableHandle<'ctx> { type Row = PkString; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for PkStringTableHandle<'ctx> { } } -pub struct PkStringUpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("pk_string"); + _table.add_unique_constraint::("s", |row| &row.s); +} +pub struct PkStringUpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkStringTableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for PkStringTableHandle<'ctx> { type UpdateCallbackId = PkStringUpdateCallbackId; fn on_update( @@ -102,12 +106,9 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkStringTableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::( - raw_updates, - |row: &PkString| &row.s, - ) - .context("Failed to parse table update for table \"pk_string\"") +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkString| &row.s) + .context("Failed to parse table update for table \"pk_string\"") } /// Access to the `s` unique index on the table `pk_string`, @@ -118,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_string().s().find(...)`. pub struct PkStringSUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -126,7 +127,7 @@ impl<'ctx> PkStringTableHandle<'ctx> { /// Get a handle on the `s` unique index on the table `pk_string`. pub fn s(&self) -> PkStringSUnique<'ctx> { PkStringSUnique { - imp: self.imp.get_unique_constraint::("s", |row| &row.s), + imp: self.imp.get_unique_constraint::("s"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_string_type.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_string_type.rs index a5bca35544a..2ee0eae8b69 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_string_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_string_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct PkString { pub data: i32, } -impl __sdk::spacetime_module::InModule for PkString { +impl __sdk::InModule for PkString { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_u_128_table.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_u_128_table.rs index b8425759a75..0e322646b53 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_u_128_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_u_128_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::pk_u_128_type::PkU128; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `pk_u128`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.pk_u_128().on_insert(...)`. pub struct PkU128TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl PkU128TableAccess for super::RemoteTables { } } -pub struct PkU128InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkU128DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkU128InsertCallbackId(__sdk::CallbackId); +pub struct PkU128DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkU128TableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkU128TableHandle<'ctx> { type Row = PkU128; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for PkU128TableHandle<'ctx> { } } -pub struct PkU128UpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("pk_u128"); + _table.add_unique_constraint::("n", |row| &row.n); +} +pub struct PkU128UpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkU128TableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for PkU128TableHandle<'ctx> { type UpdateCallbackId = PkU128UpdateCallbackId; fn on_update( @@ -102,11 +106,9 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkU128TableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkU128| { - &row.n - }) - .context("Failed to parse table update for table \"pk_u128\"") +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkU128| &row.n) + .context("Failed to parse table update for table \"pk_u128\"") } /// Access to the `n` unique index on the table `pk_u128`, @@ -117,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_u_128().n().find(...)`. pub struct PkU128NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -125,7 +127,7 @@ impl<'ctx> PkU128TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `pk_u128`. pub fn n(&self) -> PkU128NUnique<'ctx> { PkU128NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_u_128_type.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_u_128_type.rs index 107c9f7fe24..2eb0d08b61f 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_u_128_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_u_128_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct PkU128 { pub data: i32, } -impl __sdk::spacetime_module::InModule for PkU128 { +impl __sdk::InModule for PkU128 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_u_16_table.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_u_16_table.rs index 1efb9d500be..c831784bea8 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_u_16_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_u_16_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::pk_u_16_type::PkU16; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `pk_u16`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.pk_u_16().on_insert(...)`. pub struct PkU16TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl PkU16TableAccess for super::RemoteTables { } } -pub struct PkU16InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkU16DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkU16InsertCallbackId(__sdk::CallbackId); +pub struct PkU16DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkU16TableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkU16TableHandle<'ctx> { type Row = PkU16; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for PkU16TableHandle<'ctx> { } } -pub struct PkU16UpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("pk_u16"); + _table.add_unique_constraint::("n", |row| &row.n); +} +pub struct PkU16UpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkU16TableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for PkU16TableHandle<'ctx> { type UpdateCallbackId = PkU16UpdateCallbackId; fn on_update( @@ -102,8 +106,8 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkU16TableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkU16| &row.n) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkU16| &row.n) .context("Failed to parse table update for table \"pk_u16\"") } @@ -115,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_u_16().n().find(...)`. pub struct PkU16NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -123,7 +127,7 @@ impl<'ctx> PkU16TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `pk_u16`. pub fn n(&self) -> PkU16NUnique<'ctx> { PkU16NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_u_16_type.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_u_16_type.rs index a884771afca..3e15afd7d58 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_u_16_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_u_16_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct PkU16 { pub data: i32, } -impl __sdk::spacetime_module::InModule for PkU16 { +impl __sdk::InModule for PkU16 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_u_256_table.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_u_256_table.rs index e07c92156c4..c2cda6d7680 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_u_256_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_u_256_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::pk_u_256_type::PkU256; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `pk_u256`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.pk_u_256().on_insert(...)`. pub struct PkU256TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl PkU256TableAccess for super::RemoteTables { } } -pub struct PkU256InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkU256DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkU256InsertCallbackId(__sdk::CallbackId); +pub struct PkU256DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkU256TableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkU256TableHandle<'ctx> { type Row = PkU256; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for PkU256TableHandle<'ctx> { } } -pub struct PkU256UpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("pk_u256"); + _table.add_unique_constraint::<__sats::u256>("n", |row| &row.n); +} +pub struct PkU256UpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkU256TableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for PkU256TableHandle<'ctx> { type UpdateCallbackId = PkU256UpdateCallbackId; fn on_update( @@ -102,12 +106,9 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkU256TableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::<__sats::u256>( - raw_updates, - |row: &PkU256| &row.n, - ) - .context("Failed to parse table update for table \"pk_u256\"") +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::<__sats::u256>(raw_updates, |row: &PkU256| &row.n) + .context("Failed to parse table update for table \"pk_u256\"") } /// Access to the `n` unique index on the table `pk_u256`, @@ -118,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_u_256().n().find(...)`. pub struct PkU256NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -126,7 +127,7 @@ impl<'ctx> PkU256TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `pk_u256`. pub fn n(&self) -> PkU256NUnique<'ctx> { PkU256NUnique { - imp: self.imp.get_unique_constraint::<__sats::u256>("n", |row| &row.n), + imp: self.imp.get_unique_constraint::<__sats::u256>("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_u_256_type.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_u_256_type.rs index a1ea95d0e91..b3bb0084270 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_u_256_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_u_256_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct PkU256 { pub data: i32, } -impl __sdk::spacetime_module::InModule for PkU256 { +impl __sdk::InModule for PkU256 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_u_32_table.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_u_32_table.rs index 1f995680e8e..5bc5f6961f6 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_u_32_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_u_32_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::pk_u_32_type::PkU32; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `pk_u32`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.pk_u_32().on_insert(...)`. pub struct PkU32TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl PkU32TableAccess for super::RemoteTables { } } -pub struct PkU32InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkU32DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkU32InsertCallbackId(__sdk::CallbackId); +pub struct PkU32DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkU32TableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkU32TableHandle<'ctx> { type Row = PkU32; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for PkU32TableHandle<'ctx> { } } -pub struct PkU32UpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("pk_u32"); + _table.add_unique_constraint::("n", |row| &row.n); +} +pub struct PkU32UpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkU32TableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for PkU32TableHandle<'ctx> { type UpdateCallbackId = PkU32UpdateCallbackId; fn on_update( @@ -102,8 +106,8 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkU32TableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkU32| &row.n) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkU32| &row.n) .context("Failed to parse table update for table \"pk_u32\"") } @@ -115,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_u_32().n().find(...)`. pub struct PkU32NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -123,7 +127,7 @@ impl<'ctx> PkU32TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `pk_u32`. pub fn n(&self) -> PkU32NUnique<'ctx> { PkU32NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_u_32_type.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_u_32_type.rs index 79c33226b00..35ba9871dba 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_u_32_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_u_32_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct PkU32 { pub data: i32, } -impl __sdk::spacetime_module::InModule for PkU32 { +impl __sdk::InModule for PkU32 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_u_64_table.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_u_64_table.rs index edafc0348ce..b5320f281d5 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_u_64_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_u_64_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::pk_u_64_type::PkU64; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `pk_u64`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.pk_u_64().on_insert(...)`. pub struct PkU64TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl PkU64TableAccess for super::RemoteTables { } } -pub struct PkU64InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkU64DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkU64InsertCallbackId(__sdk::CallbackId); +pub struct PkU64DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkU64TableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkU64TableHandle<'ctx> { type Row = PkU64; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for PkU64TableHandle<'ctx> { } } -pub struct PkU64UpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("pk_u64"); + _table.add_unique_constraint::("n", |row| &row.n); +} +pub struct PkU64UpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkU64TableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for PkU64TableHandle<'ctx> { type UpdateCallbackId = PkU64UpdateCallbackId; fn on_update( @@ -102,8 +106,8 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkU64TableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkU64| &row.n) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkU64| &row.n) .context("Failed to parse table update for table \"pk_u64\"") } @@ -115,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_u_64().n().find(...)`. pub struct PkU64NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -123,7 +127,7 @@ impl<'ctx> PkU64TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `pk_u64`. pub fn n(&self) -> PkU64NUnique<'ctx> { PkU64NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_u_64_type.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_u_64_type.rs index 4f49fd8bbb5..59a50e24281 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_u_64_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_u_64_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct PkU64 { pub data: i32, } -impl __sdk::spacetime_module::InModule for PkU64 { +impl __sdk::InModule for PkU64 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_u_8_table.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_u_8_table.rs index ad9341838ce..03fdb5a319f 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_u_8_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_u_8_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::pk_u_8_type::PkU8; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `pk_u8`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.pk_u_8().on_insert(...)`. pub struct PkU8TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl PkU8TableAccess for super::RemoteTables { } } -pub struct PkU8InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct PkU8DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct PkU8InsertCallbackId(__sdk::CallbackId); +pub struct PkU8DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for PkU8TableHandle<'ctx> { +impl<'ctx> __sdk::Table for PkU8TableHandle<'ctx> { type Row = PkU8; type EventContext = super::EventContext; @@ -82,9 +81,14 @@ impl<'ctx> __sdk::table::Table for PkU8TableHandle<'ctx> { } } -pub struct PkU8UpdateCallbackId(__sdk::callbacks::CallbackId); +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("pk_u8"); + _table.add_unique_constraint::("n", |row| &row.n); +} +pub struct PkU8UpdateCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::TableWithPrimaryKey for PkU8TableHandle<'ctx> { +impl<'ctx> __sdk::TableWithPrimaryKey for PkU8TableHandle<'ctx> { type UpdateCallbackId = PkU8UpdateCallbackId; fn on_update( @@ -102,8 +106,8 @@ impl<'ctx> __sdk::table::TableWithPrimaryKey for PkU8TableHandle<'ctx> { #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkU8| &row.n) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &PkU8| &row.n) .context("Failed to parse table update for table \"pk_u8\"") } @@ -115,7 +119,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.pk_u_8().n().find(...)`. pub struct PkU8NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -123,7 +127,7 @@ impl<'ctx> PkU8TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `pk_u8`. pub fn n(&self) -> PkU8NUnique<'ctx> { PkU8NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/pk_u_8_type.rs b/crates/sdk/tests/test-client/src/module_bindings/pk_u_8_type.rs index c080d9d2136..53269b51e45 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/pk_u_8_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/pk_u_8_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct PkU8 { pub data: i32, } -impl __sdk::spacetime_module::InModule for PkU8 { +impl __sdk::InModule for PkU8 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/scheduled_table_table.rs b/crates/sdk/tests/test-client/src/module_bindings/scheduled_table_table.rs new file mode 100644 index 00000000000..cd9cf2faeda --- /dev/null +++ b/crates/sdk/tests/test-client/src/module_bindings/scheduled_table_table.rs @@ -0,0 +1,144 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. + +#![allow(unused)] +use super::scheduled_table_type::ScheduledTable; +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, + anyhow::{self as __anyhow, Context as _}, +}; + +/// Table handle for the table `scheduled_table`. +/// +/// Obtain a handle from the [`ScheduledTableTableAccess::scheduled_table`] method on [`super::RemoteTables`], +/// like `ctx.db.scheduled_table()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.scheduled_table().on_insert(...)`. +pub struct ScheduledTableTableHandle<'ctx> { + imp: __sdk::TableHandle, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `scheduled_table`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait ScheduledTableTableAccess { + #[allow(non_snake_case)] + /// Obtain a [`ScheduledTableTableHandle`], which mediates access to the table `scheduled_table`. + fn scheduled_table(&self) -> ScheduledTableTableHandle<'_>; +} + +impl ScheduledTableTableAccess for super::RemoteTables { + fn scheduled_table(&self) -> ScheduledTableTableHandle<'_> { + ScheduledTableTableHandle { + imp: self.imp.get_table::("scheduled_table"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct ScheduledTableInsertCallbackId(__sdk::CallbackId); +pub struct ScheduledTableDeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for ScheduledTableTableHandle<'ctx> { + type Row = ScheduledTable; + type EventContext = super::EventContext; + + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } + + type InsertCallbackId = ScheduledTableInsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> ScheduledTableInsertCallbackId { + ScheduledTableInsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: ScheduledTableInsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = ScheduledTableDeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> ScheduledTableDeleteCallbackId { + ScheduledTableDeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: ScheduledTableDeleteCallbackId) { + self.imp.remove_on_delete(callback.0) + } +} + +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("scheduled_table"); + _table.add_unique_constraint::("scheduled_id", |row| &row.scheduled_id); +} +pub struct ScheduledTableUpdateCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::TableWithPrimaryKey for ScheduledTableTableHandle<'ctx> { + type UpdateCallbackId = ScheduledTableUpdateCallbackId; + + fn on_update( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static, + ) -> ScheduledTableUpdateCallbackId { + ScheduledTableUpdateCallbackId(self.imp.on_update(Box::new(callback))) + } + + fn remove_on_update(&self, callback: ScheduledTableUpdateCallbackId) { + self.imp.remove_on_update(callback.0) + } +} + +#[doc(hidden)] +pub(super) fn parse_table_update( + raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_with_primary_key::(raw_updates, |row: &ScheduledTable| { + &row.scheduled_id + }) + .context("Failed to parse table update for table \"scheduled_table\"") +} + +/// Access to the `scheduled_id` unique index on the table `scheduled_table`, +/// which allows point queries on the field of the same name +/// via the [`ScheduledTableScheduledIdUnique::find`] method. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.scheduled_table().scheduled_id().find(...)`. +pub struct ScheduledTableScheduledIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +impl<'ctx> ScheduledTableTableHandle<'ctx> { + /// Get a handle on the `scheduled_id` unique index on the table `scheduled_table`. + pub fn scheduled_id(&self) -> ScheduledTableScheduledIdUnique<'ctx> { + ScheduledTableScheduledIdUnique { + imp: self.imp.get_unique_constraint::("scheduled_id"), + phantom: std::marker::PhantomData, + } + } +} + +impl<'ctx> ScheduledTableScheduledIdUnique<'ctx> { + /// Find the subscribed row whose `scheduled_id` column value is equal to `col_val`, + /// if such a row is present in the client cache. + pub fn find(&self, col_val: &u64) -> Option { + self.imp.find(col_val) + } +} diff --git a/crates/sdk/tests/test-client/src/module_bindings/scheduled_table_type.rs b/crates/sdk/tests/test-client/src/module_bindings/scheduled_table_type.rs new file mode 100644 index 00000000000..2d2b4433987 --- /dev/null +++ b/crates/sdk/tests/test-client/src/module_bindings/scheduled_table_type.rs @@ -0,0 +1,20 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. + +#![allow(unused)] +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, + anyhow::{self as __anyhow, Context as _}, +}; + +#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] +#[sats(crate = __lib)] +pub struct ScheduledTable { + pub scheduled_id: u64, + pub scheduled_at: __sdk::ScheduleAt, + pub text: String, +} + +impl __sdk::InModule for ScheduledTable { + type Module = super::RemoteModule; +} diff --git a/crates/sdk/tests/test-client/src/module_bindings/send_scheduled_message_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/send_scheduled_message_reducer.rs new file mode 100644 index 00000000000..d78e550ce2e --- /dev/null +++ b/crates/sdk/tests/test-client/src/module_bindings/send_scheduled_message_reducer.rs @@ -0,0 +1,110 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. + +#![allow(unused)] +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, + anyhow::{self as __anyhow, Context as _}, +}; + +use super::scheduled_table_type::ScheduledTable; + +#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] +#[sats(crate = __lib)] +pub(super) struct SendScheduledMessageArgs { + pub arg: ScheduledTable, +} + +impl From for super::Reducer { + fn from(args: SendScheduledMessageArgs) -> Self { + Self::SendScheduledMessage { arg: args.arg } + } +} + +impl __sdk::InModule for SendScheduledMessageArgs { + type Module = super::RemoteModule; +} + +pub struct SendScheduledMessageCallbackId(__sdk::CallbackId); + +#[allow(non_camel_case_types)] +/// Extension trait for access to the reducer `send_scheduled_message`. +/// +/// Implemented for [`super::RemoteReducers`]. +pub trait send_scheduled_message { + /// Request that the remote module invoke the reducer `send_scheduled_message` to run as soon as possible. + /// + /// This method returns immediately, and errors only if we are unable to send the request. + /// The reducer will run asynchronously in the future, + /// and its status can be observed by listening for [`Self::on_send_scheduled_message`] callbacks. + fn send_scheduled_message(&self, arg: ScheduledTable) -> __anyhow::Result<()>; + /// Register a callback to run whenever we are notified of an invocation of the reducer `send_scheduled_message`. + /// + /// The [`super::EventContext`] passed to the `callback` + /// will always have [`__sdk::Event::Reducer`] as its `event`, + /// but it may or may not have terminated successfully and been committed. + /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::EventContext`] + /// to determine the reducer's status. + /// + /// The returned [`SendScheduledMessageCallbackId`] can be passed to [`Self::remove_on_send_scheduled_message`] + /// to cancel the callback. + fn on_send_scheduled_message( + &self, + callback: impl FnMut(&super::EventContext, &ScheduledTable) + Send + 'static, + ) -> SendScheduledMessageCallbackId; + /// Cancel a callback previously registered by [`Self::on_send_scheduled_message`], + /// causing it not to run in the future. + fn remove_on_send_scheduled_message(&self, callback: SendScheduledMessageCallbackId); +} + +impl send_scheduled_message for super::RemoteReducers { + fn send_scheduled_message(&self, arg: ScheduledTable) -> __anyhow::Result<()> { + self.imp + .call_reducer("send_scheduled_message", SendScheduledMessageArgs { arg }) + } + fn on_send_scheduled_message( + &self, + mut callback: impl FnMut(&super::EventContext, &ScheduledTable) + Send + 'static, + ) -> SendScheduledMessageCallbackId { + SendScheduledMessageCallbackId(self.imp.on_reducer( + "send_scheduled_message", + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::SendScheduledMessage { arg }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, arg) + }), + )) + } + fn remove_on_send_scheduled_message(&self, callback: SendScheduledMessageCallbackId) { + self.imp.remove_on_reducer("send_scheduled_message", callback.0) + } +} + +#[allow(non_camel_case_types)] +#[doc(hidden)] +/// Extension trait for setting the call-flags for the reducer `send_scheduled_message`. +/// +/// Implemented for [`super::SetReducerFlags`]. +/// +/// This type is currently unstable and may be removed without a major version bump. +pub trait set_flags_for_send_scheduled_message { + /// Set the call-reducer flags for the reducer `send_scheduled_message` to `flags`. + /// + /// This type is currently unstable and may be removed without a major version bump. + fn send_scheduled_message(&self, flags: __ws::CallReducerFlags); +} + +impl set_flags_for_send_scheduled_message for super::SetReducerFlags { + fn send_scheduled_message(&self, flags: __ws::CallReducerFlags) { + self.imp.set_call_reducer_flags("send_scheduled_message", flags); + } +} diff --git a/crates/sdk/tests/test-client/src/module_bindings/simple_enum_type.rs b/crates/sdk/tests/test-client/src/module_bindings/simple_enum_type.rs index c46e2b70ba0..74a7afe5066 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/simple_enum_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/simple_enum_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -18,6 +17,6 @@ pub enum SimpleEnum { Two, } -impl __sdk::spacetime_module::InModule for SimpleEnum { +impl __sdk::InModule for SimpleEnum { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/table_holds_table_table.rs b/crates/sdk/tests/test-client/src/module_bindings/table_holds_table_table.rs index 5338a65e5ba..881f15de974 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/table_holds_table_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/table_holds_table_table.rs @@ -5,10 +5,9 @@ use super::one_u_8_type::OneU8; use super::table_holds_table_type::TableHoldsTable; use super::vec_u_8_type::VecU8; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `table_holds_table`. @@ -20,7 +19,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.table_holds_table().on_insert(...)`. pub struct TableHoldsTableTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -43,10 +42,10 @@ impl TableHoldsTableTableAccess for super::RemoteTables { } } -pub struct TableHoldsTableInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct TableHoldsTableDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct TableHoldsTableInsertCallbackId(__sdk::CallbackId); +pub struct TableHoldsTableDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for TableHoldsTableTableHandle<'ctx> { +impl<'ctx> __sdk::Table for TableHoldsTableTableHandle<'ctx> { type Row = TableHoldsTable; type EventContext = super::EventContext; @@ -84,10 +83,14 @@ impl<'ctx> __sdk::table::Table for TableHoldsTableTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("table_holds_table"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"table_holds_table\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/table_holds_table_type.rs b/crates/sdk/tests/test-client/src/module_bindings/table_holds_table_type.rs index acf464861c2..31752f8a530 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/table_holds_table_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/table_holds_table_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::one_u_8_type::OneU8; @@ -18,6 +17,6 @@ pub struct TableHoldsTable { pub b: VecU8, } -impl __sdk::spacetime_module::InModule for TableHoldsTable { +impl __sdk::InModule for TableHoldsTable { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_address_table.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_address_table.rs index 01c586a33aa..0529e7ca941 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_address_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_address_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::unique_address_type::UniqueAddress; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `unique_address`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.unique_address().on_insert(...)`. pub struct UniqueAddressTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UniqueAddressTableAccess for super::RemoteTables { } } -pub struct UniqueAddressInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UniqueAddressDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UniqueAddressInsertCallbackId(__sdk::CallbackId); +pub struct UniqueAddressDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UniqueAddressTableHandle<'ctx> { +impl<'ctx> __sdk::Table for UniqueAddressTableHandle<'ctx> { type Row = UniqueAddress; type EventContext = super::EventContext; @@ -82,11 +81,16 @@ impl<'ctx> __sdk::table::Table for UniqueAddressTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("unique_address"); + _table.add_unique_constraint::<__sdk::Address>("a", |row| &row.a); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"unique_address\"") } @@ -98,7 +102,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.unique_address().a().find(...)`. pub struct UniqueAddressAUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -106,7 +110,7 @@ impl<'ctx> UniqueAddressTableHandle<'ctx> { /// Get a handle on the `a` unique index on the table `unique_address`. pub fn a(&self) -> UniqueAddressAUnique<'ctx> { UniqueAddressAUnique { - imp: self.imp.get_unique_constraint::<__sdk::Address>("a", |row| &row.a), + imp: self.imp.get_unique_constraint::<__sdk::Address>("a"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_address_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_address_type.rs index c940f48162b..6de0853896a 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_address_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_address_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct UniqueAddress { pub data: i32, } -impl __sdk::spacetime_module::InModule for UniqueAddress { +impl __sdk::InModule for UniqueAddress { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_bool_table.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_bool_table.rs index 9da44544da4..1c6eef00e4c 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_bool_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_bool_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::unique_bool_type::UniqueBool; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `unique_bool`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.unique_bool().on_insert(...)`. pub struct UniqueBoolTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UniqueBoolTableAccess for super::RemoteTables { } } -pub struct UniqueBoolInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UniqueBoolDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UniqueBoolInsertCallbackId(__sdk::CallbackId); +pub struct UniqueBoolDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UniqueBoolTableHandle<'ctx> { +impl<'ctx> __sdk::Table for UniqueBoolTableHandle<'ctx> { type Row = UniqueBool; type EventContext = super::EventContext; @@ -82,11 +81,16 @@ impl<'ctx> __sdk::table::Table for UniqueBoolTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("unique_bool"); + _table.add_unique_constraint::("b", |row| &row.b); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"unique_bool\"") } @@ -98,7 +102,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.unique_bool().b().find(...)`. pub struct UniqueBoolBUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -106,7 +110,7 @@ impl<'ctx> UniqueBoolTableHandle<'ctx> { /// Get a handle on the `b` unique index on the table `unique_bool`. pub fn b(&self) -> UniqueBoolBUnique<'ctx> { UniqueBoolBUnique { - imp: self.imp.get_unique_constraint::("b", |row| &row.b), + imp: self.imp.get_unique_constraint::("b"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_bool_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_bool_type.rs index c40d2a52cf5..f85b2eaf350 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_bool_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_bool_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct UniqueBool { pub data: i32, } -impl __sdk::spacetime_module::InModule for UniqueBool { +impl __sdk::InModule for UniqueBool { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_i_128_table.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_i_128_table.rs index 1952c45b080..800f3288f52 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_i_128_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_i_128_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::unique_i_128_type::UniqueI128; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `unique_i128`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.unique_i_128().on_insert(...)`. pub struct UniqueI128TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UniqueI128TableAccess for super::RemoteTables { } } -pub struct UniqueI128InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UniqueI128DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UniqueI128InsertCallbackId(__sdk::CallbackId); +pub struct UniqueI128DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UniqueI128TableHandle<'ctx> { +impl<'ctx> __sdk::Table for UniqueI128TableHandle<'ctx> { type Row = UniqueI128; type EventContext = super::EventContext; @@ -82,11 +81,16 @@ impl<'ctx> __sdk::table::Table for UniqueI128TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("unique_i128"); + _table.add_unique_constraint::("n", |row| &row.n); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"unique_i128\"") } @@ -98,7 +102,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.unique_i_128().n().find(...)`. pub struct UniqueI128NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -106,7 +110,7 @@ impl<'ctx> UniqueI128TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `unique_i128`. pub fn n(&self) -> UniqueI128NUnique<'ctx> { UniqueI128NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_i_128_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_i_128_type.rs index 9076f5ec459..bdd4df2f290 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_i_128_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_i_128_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct UniqueI128 { pub data: i32, } -impl __sdk::spacetime_module::InModule for UniqueI128 { +impl __sdk::InModule for UniqueI128 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_i_16_table.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_i_16_table.rs index 2ae85224ab5..7df0019bfde 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_i_16_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_i_16_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::unique_i_16_type::UniqueI16; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `unique_i16`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.unique_i_16().on_insert(...)`. pub struct UniqueI16TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UniqueI16TableAccess for super::RemoteTables { } } -pub struct UniqueI16InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UniqueI16DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UniqueI16InsertCallbackId(__sdk::CallbackId); +pub struct UniqueI16DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UniqueI16TableHandle<'ctx> { +impl<'ctx> __sdk::Table for UniqueI16TableHandle<'ctx> { type Row = UniqueI16; type EventContext = super::EventContext; @@ -82,11 +81,16 @@ impl<'ctx> __sdk::table::Table for UniqueI16TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("unique_i16"); + _table.add_unique_constraint::("n", |row| &row.n); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"unique_i16\"") } @@ -98,7 +102,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.unique_i_16().n().find(...)`. pub struct UniqueI16NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -106,7 +110,7 @@ impl<'ctx> UniqueI16TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `unique_i16`. pub fn n(&self) -> UniqueI16NUnique<'ctx> { UniqueI16NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_i_16_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_i_16_type.rs index 67ac0ba2d73..f8821b6ba7e 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_i_16_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_i_16_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct UniqueI16 { pub data: i32, } -impl __sdk::spacetime_module::InModule for UniqueI16 { +impl __sdk::InModule for UniqueI16 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_i_256_table.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_i_256_table.rs index 9b4b070dfd7..5dbec20049f 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_i_256_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_i_256_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::unique_i_256_type::UniqueI256; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `unique_i256`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.unique_i_256().on_insert(...)`. pub struct UniqueI256TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UniqueI256TableAccess for super::RemoteTables { } } -pub struct UniqueI256InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UniqueI256DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UniqueI256InsertCallbackId(__sdk::CallbackId); +pub struct UniqueI256DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UniqueI256TableHandle<'ctx> { +impl<'ctx> __sdk::Table for UniqueI256TableHandle<'ctx> { type Row = UniqueI256; type EventContext = super::EventContext; @@ -82,11 +81,16 @@ impl<'ctx> __sdk::table::Table for UniqueI256TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("unique_i256"); + _table.add_unique_constraint::<__sats::i256>("n", |row| &row.n); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"unique_i256\"") } @@ -98,7 +102,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.unique_i_256().n().find(...)`. pub struct UniqueI256NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -106,7 +110,7 @@ impl<'ctx> UniqueI256TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `unique_i256`. pub fn n(&self) -> UniqueI256NUnique<'ctx> { UniqueI256NUnique { - imp: self.imp.get_unique_constraint::<__sats::i256>("n", |row| &row.n), + imp: self.imp.get_unique_constraint::<__sats::i256>("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_i_256_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_i_256_type.rs index f6d5d02c0c9..ffd0fd7753a 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_i_256_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_i_256_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct UniqueI256 { pub data: i32, } -impl __sdk::spacetime_module::InModule for UniqueI256 { +impl __sdk::InModule for UniqueI256 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_i_32_table.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_i_32_table.rs index 14d5427a75b..b009c18d373 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_i_32_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_i_32_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::unique_i_32_type::UniqueI32; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `unique_i32`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.unique_i_32().on_insert(...)`. pub struct UniqueI32TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UniqueI32TableAccess for super::RemoteTables { } } -pub struct UniqueI32InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UniqueI32DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UniqueI32InsertCallbackId(__sdk::CallbackId); +pub struct UniqueI32DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UniqueI32TableHandle<'ctx> { +impl<'ctx> __sdk::Table for UniqueI32TableHandle<'ctx> { type Row = UniqueI32; type EventContext = super::EventContext; @@ -82,11 +81,16 @@ impl<'ctx> __sdk::table::Table for UniqueI32TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("unique_i32"); + _table.add_unique_constraint::("n", |row| &row.n); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"unique_i32\"") } @@ -98,7 +102,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.unique_i_32().n().find(...)`. pub struct UniqueI32NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -106,7 +110,7 @@ impl<'ctx> UniqueI32TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `unique_i32`. pub fn n(&self) -> UniqueI32NUnique<'ctx> { UniqueI32NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_i_32_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_i_32_type.rs index 58c252611f3..311e9242590 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_i_32_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_i_32_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct UniqueI32 { pub data: i32, } -impl __sdk::spacetime_module::InModule for UniqueI32 { +impl __sdk::InModule for UniqueI32 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_i_64_table.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_i_64_table.rs index 6eb8b35855b..67fb4eea9c7 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_i_64_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_i_64_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::unique_i_64_type::UniqueI64; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `unique_i64`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.unique_i_64().on_insert(...)`. pub struct UniqueI64TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UniqueI64TableAccess for super::RemoteTables { } } -pub struct UniqueI64InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UniqueI64DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UniqueI64InsertCallbackId(__sdk::CallbackId); +pub struct UniqueI64DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UniqueI64TableHandle<'ctx> { +impl<'ctx> __sdk::Table for UniqueI64TableHandle<'ctx> { type Row = UniqueI64; type EventContext = super::EventContext; @@ -82,11 +81,16 @@ impl<'ctx> __sdk::table::Table for UniqueI64TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("unique_i64"); + _table.add_unique_constraint::("n", |row| &row.n); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"unique_i64\"") } @@ -98,7 +102,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.unique_i_64().n().find(...)`. pub struct UniqueI64NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -106,7 +110,7 @@ impl<'ctx> UniqueI64TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `unique_i64`. pub fn n(&self) -> UniqueI64NUnique<'ctx> { UniqueI64NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_i_64_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_i_64_type.rs index fb55f1ead9f..e4fdfaafee7 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_i_64_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_i_64_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct UniqueI64 { pub data: i32, } -impl __sdk::spacetime_module::InModule for UniqueI64 { +impl __sdk::InModule for UniqueI64 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_i_8_table.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_i_8_table.rs index 7a26c27d7fa..f2b0024e213 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_i_8_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_i_8_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::unique_i_8_type::UniqueI8; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `unique_i8`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.unique_i_8().on_insert(...)`. pub struct UniqueI8TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UniqueI8TableAccess for super::RemoteTables { } } -pub struct UniqueI8InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UniqueI8DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UniqueI8InsertCallbackId(__sdk::CallbackId); +pub struct UniqueI8DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UniqueI8TableHandle<'ctx> { +impl<'ctx> __sdk::Table for UniqueI8TableHandle<'ctx> { type Row = UniqueI8; type EventContext = super::EventContext; @@ -82,11 +81,16 @@ impl<'ctx> __sdk::table::Table for UniqueI8TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("unique_i8"); + _table.add_unique_constraint::("n", |row| &row.n); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"unique_i8\"") } @@ -98,7 +102,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.unique_i_8().n().find(...)`. pub struct UniqueI8NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -106,7 +110,7 @@ impl<'ctx> UniqueI8TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `unique_i8`. pub fn n(&self) -> UniqueI8NUnique<'ctx> { UniqueI8NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_i_8_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_i_8_type.rs index 750271ff882..c341e374fff 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_i_8_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_i_8_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct UniqueI8 { pub data: i32, } -impl __sdk::spacetime_module::InModule for UniqueI8 { +impl __sdk::InModule for UniqueI8 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_identity_table.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_identity_table.rs index 54988ef2790..34a768c8974 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_identity_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_identity_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::unique_identity_type::UniqueIdentity; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `unique_identity`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.unique_identity().on_insert(...)`. pub struct UniqueIdentityTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UniqueIdentityTableAccess for super::RemoteTables { } } -pub struct UniqueIdentityInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UniqueIdentityDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UniqueIdentityInsertCallbackId(__sdk::CallbackId); +pub struct UniqueIdentityDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UniqueIdentityTableHandle<'ctx> { +impl<'ctx> __sdk::Table for UniqueIdentityTableHandle<'ctx> { type Row = UniqueIdentity; type EventContext = super::EventContext; @@ -82,11 +81,16 @@ impl<'ctx> __sdk::table::Table for UniqueIdentityTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("unique_identity"); + _table.add_unique_constraint::<__sdk::Identity>("i", |row| &row.i); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"unique_identity\"") } @@ -98,7 +102,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.unique_identity().i().find(...)`. pub struct UniqueIdentityIUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -106,7 +110,7 @@ impl<'ctx> UniqueIdentityTableHandle<'ctx> { /// Get a handle on the `i` unique index on the table `unique_identity`. pub fn i(&self) -> UniqueIdentityIUnique<'ctx> { UniqueIdentityIUnique { - imp: self.imp.get_unique_constraint::<__sdk::Identity>("i", |row| &row.i), + imp: self.imp.get_unique_constraint::<__sdk::Identity>("i"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_identity_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_identity_type.rs index 4920d186588..41b75149613 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_identity_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_identity_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct UniqueIdentity { pub data: i32, } -impl __sdk::spacetime_module::InModule for UniqueIdentity { +impl __sdk::InModule for UniqueIdentity { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_string_table.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_string_table.rs index 4b47857172c..399b0e2560a 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_string_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_string_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::unique_string_type::UniqueString; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `unique_string`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.unique_string().on_insert(...)`. pub struct UniqueStringTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UniqueStringTableAccess for super::RemoteTables { } } -pub struct UniqueStringInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UniqueStringDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UniqueStringInsertCallbackId(__sdk::CallbackId); +pub struct UniqueStringDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UniqueStringTableHandle<'ctx> { +impl<'ctx> __sdk::Table for UniqueStringTableHandle<'ctx> { type Row = UniqueString; type EventContext = super::EventContext; @@ -82,11 +81,16 @@ impl<'ctx> __sdk::table::Table for UniqueStringTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("unique_string"); + _table.add_unique_constraint::("s", |row| &row.s); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"unique_string\"") } @@ -98,7 +102,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.unique_string().s().find(...)`. pub struct UniqueStringSUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -106,7 +110,7 @@ impl<'ctx> UniqueStringTableHandle<'ctx> { /// Get a handle on the `s` unique index on the table `unique_string`. pub fn s(&self) -> UniqueStringSUnique<'ctx> { UniqueStringSUnique { - imp: self.imp.get_unique_constraint::("s", |row| &row.s), + imp: self.imp.get_unique_constraint::("s"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_string_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_string_type.rs index 60a0ed71100..3cebe5bd991 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_string_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_string_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct UniqueString { pub data: i32, } -impl __sdk::spacetime_module::InModule for UniqueString { +impl __sdk::InModule for UniqueString { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_u_128_table.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_u_128_table.rs index 63b568ee3ef..2d645d34fe3 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_u_128_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_u_128_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::unique_u_128_type::UniqueU128; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `unique_u128`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.unique_u_128().on_insert(...)`. pub struct UniqueU128TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UniqueU128TableAccess for super::RemoteTables { } } -pub struct UniqueU128InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UniqueU128DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UniqueU128InsertCallbackId(__sdk::CallbackId); +pub struct UniqueU128DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UniqueU128TableHandle<'ctx> { +impl<'ctx> __sdk::Table for UniqueU128TableHandle<'ctx> { type Row = UniqueU128; type EventContext = super::EventContext; @@ -82,11 +81,16 @@ impl<'ctx> __sdk::table::Table for UniqueU128TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("unique_u128"); + _table.add_unique_constraint::("n", |row| &row.n); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"unique_u128\"") } @@ -98,7 +102,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.unique_u_128().n().find(...)`. pub struct UniqueU128NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -106,7 +110,7 @@ impl<'ctx> UniqueU128TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `unique_u128`. pub fn n(&self) -> UniqueU128NUnique<'ctx> { UniqueU128NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_u_128_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_u_128_type.rs index 8952e3c7abf..b52b1cdb4ff 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_u_128_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_u_128_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct UniqueU128 { pub data: i32, } -impl __sdk::spacetime_module::InModule for UniqueU128 { +impl __sdk::InModule for UniqueU128 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_u_16_table.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_u_16_table.rs index fb545de33b2..9de6e170edd 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_u_16_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_u_16_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::unique_u_16_type::UniqueU16; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `unique_u16`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.unique_u_16().on_insert(...)`. pub struct UniqueU16TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UniqueU16TableAccess for super::RemoteTables { } } -pub struct UniqueU16InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UniqueU16DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UniqueU16InsertCallbackId(__sdk::CallbackId); +pub struct UniqueU16DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UniqueU16TableHandle<'ctx> { +impl<'ctx> __sdk::Table for UniqueU16TableHandle<'ctx> { type Row = UniqueU16; type EventContext = super::EventContext; @@ -82,11 +81,16 @@ impl<'ctx> __sdk::table::Table for UniqueU16TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("unique_u16"); + _table.add_unique_constraint::("n", |row| &row.n); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"unique_u16\"") } @@ -98,7 +102,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.unique_u_16().n().find(...)`. pub struct UniqueU16NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -106,7 +110,7 @@ impl<'ctx> UniqueU16TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `unique_u16`. pub fn n(&self) -> UniqueU16NUnique<'ctx> { UniqueU16NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_u_16_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_u_16_type.rs index 1b43c92d2a0..920215e05e3 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_u_16_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_u_16_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct UniqueU16 { pub data: i32, } -impl __sdk::spacetime_module::InModule for UniqueU16 { +impl __sdk::InModule for UniqueU16 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_u_256_table.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_u_256_table.rs index 0bf15128245..b127f97adb8 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_u_256_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_u_256_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::unique_u_256_type::UniqueU256; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `unique_u256`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.unique_u_256().on_insert(...)`. pub struct UniqueU256TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UniqueU256TableAccess for super::RemoteTables { } } -pub struct UniqueU256InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UniqueU256DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UniqueU256InsertCallbackId(__sdk::CallbackId); +pub struct UniqueU256DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UniqueU256TableHandle<'ctx> { +impl<'ctx> __sdk::Table for UniqueU256TableHandle<'ctx> { type Row = UniqueU256; type EventContext = super::EventContext; @@ -82,11 +81,16 @@ impl<'ctx> __sdk::table::Table for UniqueU256TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("unique_u256"); + _table.add_unique_constraint::<__sats::u256>("n", |row| &row.n); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"unique_u256\"") } @@ -98,7 +102,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.unique_u_256().n().find(...)`. pub struct UniqueU256NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -106,7 +110,7 @@ impl<'ctx> UniqueU256TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `unique_u256`. pub fn n(&self) -> UniqueU256NUnique<'ctx> { UniqueU256NUnique { - imp: self.imp.get_unique_constraint::<__sats::u256>("n", |row| &row.n), + imp: self.imp.get_unique_constraint::<__sats::u256>("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_u_256_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_u_256_type.rs index 512f27a327d..3cb05024d0a 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_u_256_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_u_256_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct UniqueU256 { pub data: i32, } -impl __sdk::spacetime_module::InModule for UniqueU256 { +impl __sdk::InModule for UniqueU256 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_u_32_table.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_u_32_table.rs index ad2b997b57e..1e70d775ece 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_u_32_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_u_32_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::unique_u_32_type::UniqueU32; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `unique_u32`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.unique_u_32().on_insert(...)`. pub struct UniqueU32TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UniqueU32TableAccess for super::RemoteTables { } } -pub struct UniqueU32InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UniqueU32DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UniqueU32InsertCallbackId(__sdk::CallbackId); +pub struct UniqueU32DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UniqueU32TableHandle<'ctx> { +impl<'ctx> __sdk::Table for UniqueU32TableHandle<'ctx> { type Row = UniqueU32; type EventContext = super::EventContext; @@ -82,11 +81,16 @@ impl<'ctx> __sdk::table::Table for UniqueU32TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("unique_u32"); + _table.add_unique_constraint::("n", |row| &row.n); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"unique_u32\"") } @@ -98,7 +102,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.unique_u_32().n().find(...)`. pub struct UniqueU32NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -106,7 +110,7 @@ impl<'ctx> UniqueU32TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `unique_u32`. pub fn n(&self) -> UniqueU32NUnique<'ctx> { UniqueU32NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_u_32_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_u_32_type.rs index 8095dd764e8..e638dc9d1fe 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_u_32_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_u_32_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct UniqueU32 { pub data: i32, } -impl __sdk::spacetime_module::InModule for UniqueU32 { +impl __sdk::InModule for UniqueU32 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_u_64_table.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_u_64_table.rs index 10b3a652a5f..f10368b8e3b 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_u_64_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_u_64_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::unique_u_64_type::UniqueU64; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `unique_u64`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.unique_u_64().on_insert(...)`. pub struct UniqueU64TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UniqueU64TableAccess for super::RemoteTables { } } -pub struct UniqueU64InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UniqueU64DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UniqueU64InsertCallbackId(__sdk::CallbackId); +pub struct UniqueU64DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UniqueU64TableHandle<'ctx> { +impl<'ctx> __sdk::Table for UniqueU64TableHandle<'ctx> { type Row = UniqueU64; type EventContext = super::EventContext; @@ -82,11 +81,16 @@ impl<'ctx> __sdk::table::Table for UniqueU64TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("unique_u64"); + _table.add_unique_constraint::("n", |row| &row.n); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"unique_u64\"") } @@ -98,7 +102,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.unique_u_64().n().find(...)`. pub struct UniqueU64NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -106,7 +110,7 @@ impl<'ctx> UniqueU64TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `unique_u64`. pub fn n(&self) -> UniqueU64NUnique<'ctx> { UniqueU64NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_u_64_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_u_64_type.rs index 2a5ef0da129..c8aff5bdbfa 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_u_64_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_u_64_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct UniqueU64 { pub data: i32, } -impl __sdk::spacetime_module::InModule for UniqueU64 { +impl __sdk::InModule for UniqueU64 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_u_8_table.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_u_8_table.rs index 18f9d78c2a8..d14d70c14e2 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_u_8_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_u_8_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::unique_u_8_type::UniqueU8; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `unique_u8`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.unique_u_8().on_insert(...)`. pub struct UniqueU8TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl UniqueU8TableAccess for super::RemoteTables { } } -pub struct UniqueU8InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct UniqueU8DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct UniqueU8InsertCallbackId(__sdk::CallbackId); +pub struct UniqueU8DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for UniqueU8TableHandle<'ctx> { +impl<'ctx> __sdk::Table for UniqueU8TableHandle<'ctx> { type Row = UniqueU8; type EventContext = super::EventContext; @@ -82,11 +81,16 @@ impl<'ctx> __sdk::table::Table for UniqueU8TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("unique_u8"); + _table.add_unique_constraint::("n", |row| &row.n); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"unique_u8\"") } @@ -98,7 +102,7 @@ pub(super) fn parse_table_update( /// but to directly chain method calls, /// like `ctx.db.unique_u_8().n().find(...)`. pub struct UniqueU8NUnique<'ctx> { - imp: __sdk::client_cache::UniqueConstraint, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -106,7 +110,7 @@ impl<'ctx> UniqueU8TableHandle<'ctx> { /// Get a handle on the `n` unique index on the table `unique_u8`. pub fn n(&self) -> UniqueU8NUnique<'ctx> { UniqueU8NUnique { - imp: self.imp.get_unique_constraint::("n", |row| &row.n), + imp: self.imp.get_unique_constraint::("n"), phantom: std::marker::PhantomData, } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unique_u_8_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unique_u_8_type.rs index ac0d8d18ffa..d11dc3b2c6c 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unique_u_8_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unique_u_8_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -15,6 +14,6 @@ pub struct UniqueU8 { pub data: i32, } -impl __sdk::spacetime_module::InModule for UniqueU8 { +impl __sdk::InModule for UniqueU8 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/unit_struct_type.rs b/crates/sdk/tests/test-client/src/module_bindings/unit_struct_type.rs index 711ac0b9e75..ad8df786bbc 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/unit_struct_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/unit_struct_type.rs @@ -2,16 +2,15 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] pub struct UnitStruct {} -impl __sdk::spacetime_module::InModule for UnitStruct { +impl __sdk::InModule for UnitStruct { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_pk_address_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_pk_address_reducer.rs index eaa5ef67c19..47efac2dafe 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_pk_address_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_pk_address_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdatePkAddress { +pub(super) struct UpdatePkAddressArgs { pub a: __sdk::Address, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdatePkAddress { +impl From for super::Reducer { + fn from(args: UpdatePkAddressArgs) -> Self { + Self::UpdatePkAddress { + a: args.a, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdatePkAddressArgs { type Module = super::RemoteModule; } -pub struct UpdatePkAddressCallbackId(__sdk::callbacks::CallbackId); +pub struct UpdatePkAddressCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_pk_address`. @@ -53,20 +61,33 @@ pub trait update_pk_address { impl update_pk_address for super::RemoteReducers { fn update_pk_address(&self, a: __sdk::Address, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_pk_address", UpdatePkAddress { a, data }) + self.imp + .call_reducer("update_pk_address", UpdatePkAddressArgs { a, data }) } fn on_update_pk_address( &self, mut callback: impl FnMut(&super::EventContext, &__sdk::Address, &i32) + Send + 'static, ) -> UpdatePkAddressCallbackId { - UpdatePkAddressCallbackId(self.imp.on_reducer::( + UpdatePkAddressCallbackId(self.imp.on_reducer( "update_pk_address", - Box::new(move |ctx: &super::EventContext, args: &UpdatePkAddress| callback(ctx, &args.a, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdatePkAddress { a, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, a, data) + }), )) } fn remove_on_update_pk_address(&self, callback: UpdatePkAddressCallbackId) { - self.imp - .remove_on_reducer::("update_pk_address", callback.0) + self.imp.remove_on_reducer("update_pk_address", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_pk_bool_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_pk_bool_reducer.rs index 98060ce67d5..68443e5ffec 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_pk_bool_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_pk_bool_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdatePkBool { +pub(super) struct UpdatePkBoolArgs { pub b: bool, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdatePkBool { +impl From for super::Reducer { + fn from(args: UpdatePkBoolArgs) -> Self { + Self::UpdatePkBool { + b: args.b, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdatePkBoolArgs { type Module = super::RemoteModule; } -pub struct UpdatePkBoolCallbackId(__sdk::callbacks::CallbackId); +pub struct UpdatePkBoolCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_pk_bool`. @@ -53,19 +61,32 @@ pub trait update_pk_bool { impl update_pk_bool for super::RemoteReducers { fn update_pk_bool(&self, b: bool, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_pk_bool", UpdatePkBool { b, data }) + self.imp.call_reducer("update_pk_bool", UpdatePkBoolArgs { b, data }) } fn on_update_pk_bool( &self, mut callback: impl FnMut(&super::EventContext, &bool, &i32) + Send + 'static, ) -> UpdatePkBoolCallbackId { - UpdatePkBoolCallbackId(self.imp.on_reducer::( + UpdatePkBoolCallbackId(self.imp.on_reducer( "update_pk_bool", - Box::new(move |ctx: &super::EventContext, args: &UpdatePkBool| callback(ctx, &args.b, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdatePkBool { b, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, b, data) + }), )) } fn remove_on_update_pk_bool(&self, callback: UpdatePkBoolCallbackId) { - self.imp.remove_on_reducer::("update_pk_bool", callback.0) + self.imp.remove_on_reducer("update_pk_bool", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_128_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_128_reducer.rs index 57507dc1a03..b0e1f0d9a19 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_128_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_128_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdatePkI128 { +pub(super) struct UpdatePkI128Args { pub n: i128, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdatePkI128 { +impl From for super::Reducer { + fn from(args: UpdatePkI128Args) -> Self { + Self::UpdatePkI128 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdatePkI128Args { type Module = super::RemoteModule; } -pub struct UpdatePkI128CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdatePkI128CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_pk_i128`. @@ -53,19 +61,32 @@ pub trait update_pk_i_128 { impl update_pk_i_128 for super::RemoteReducers { fn update_pk_i_128(&self, n: i128, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_pk_i128", UpdatePkI128 { n, data }) + self.imp.call_reducer("update_pk_i128", UpdatePkI128Args { n, data }) } fn on_update_pk_i_128( &self, mut callback: impl FnMut(&super::EventContext, &i128, &i32) + Send + 'static, ) -> UpdatePkI128CallbackId { - UpdatePkI128CallbackId(self.imp.on_reducer::( + UpdatePkI128CallbackId(self.imp.on_reducer( "update_pk_i128", - Box::new(move |ctx: &super::EventContext, args: &UpdatePkI128| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdatePkI128 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_pk_i_128(&self, callback: UpdatePkI128CallbackId) { - self.imp.remove_on_reducer::("update_pk_i128", callback.0) + self.imp.remove_on_reducer("update_pk_i128", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_16_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_16_reducer.rs index 19d068bf77c..1283638b2e8 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_16_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_16_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdatePkI16 { +pub(super) struct UpdatePkI16Args { pub n: i16, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdatePkI16 { +impl From for super::Reducer { + fn from(args: UpdatePkI16Args) -> Self { + Self::UpdatePkI16 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdatePkI16Args { type Module = super::RemoteModule; } -pub struct UpdatePkI16CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdatePkI16CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_pk_i16`. @@ -53,19 +61,32 @@ pub trait update_pk_i_16 { impl update_pk_i_16 for super::RemoteReducers { fn update_pk_i_16(&self, n: i16, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_pk_i16", UpdatePkI16 { n, data }) + self.imp.call_reducer("update_pk_i16", UpdatePkI16Args { n, data }) } fn on_update_pk_i_16( &self, mut callback: impl FnMut(&super::EventContext, &i16, &i32) + Send + 'static, ) -> UpdatePkI16CallbackId { - UpdatePkI16CallbackId(self.imp.on_reducer::( + UpdatePkI16CallbackId(self.imp.on_reducer( "update_pk_i16", - Box::new(move |ctx: &super::EventContext, args: &UpdatePkI16| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdatePkI16 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_pk_i_16(&self, callback: UpdatePkI16CallbackId) { - self.imp.remove_on_reducer::("update_pk_i16", callback.0) + self.imp.remove_on_reducer("update_pk_i16", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_256_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_256_reducer.rs index 3172fe37607..3ad6ca1082e 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_256_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_256_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdatePkI256 { +pub(super) struct UpdatePkI256Args { pub n: __sats::i256, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdatePkI256 { +impl From for super::Reducer { + fn from(args: UpdatePkI256Args) -> Self { + Self::UpdatePkI256 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdatePkI256Args { type Module = super::RemoteModule; } -pub struct UpdatePkI256CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdatePkI256CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_pk_i256`. @@ -53,19 +61,32 @@ pub trait update_pk_i_256 { impl update_pk_i_256 for super::RemoteReducers { fn update_pk_i_256(&self, n: __sats::i256, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_pk_i256", UpdatePkI256 { n, data }) + self.imp.call_reducer("update_pk_i256", UpdatePkI256Args { n, data }) } fn on_update_pk_i_256( &self, mut callback: impl FnMut(&super::EventContext, &__sats::i256, &i32) + Send + 'static, ) -> UpdatePkI256CallbackId { - UpdatePkI256CallbackId(self.imp.on_reducer::( + UpdatePkI256CallbackId(self.imp.on_reducer( "update_pk_i256", - Box::new(move |ctx: &super::EventContext, args: &UpdatePkI256| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdatePkI256 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_pk_i_256(&self, callback: UpdatePkI256CallbackId) { - self.imp.remove_on_reducer::("update_pk_i256", callback.0) + self.imp.remove_on_reducer("update_pk_i256", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_32_reducer.rs index 2087c38d060..9af9bf9515b 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_32_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdatePkI32 { +pub(super) struct UpdatePkI32Args { pub n: i32, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdatePkI32 { +impl From for super::Reducer { + fn from(args: UpdatePkI32Args) -> Self { + Self::UpdatePkI32 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdatePkI32Args { type Module = super::RemoteModule; } -pub struct UpdatePkI32CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdatePkI32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_pk_i32`. @@ -53,19 +61,32 @@ pub trait update_pk_i_32 { impl update_pk_i_32 for super::RemoteReducers { fn update_pk_i_32(&self, n: i32, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_pk_i32", UpdatePkI32 { n, data }) + self.imp.call_reducer("update_pk_i32", UpdatePkI32Args { n, data }) } fn on_update_pk_i_32( &self, mut callback: impl FnMut(&super::EventContext, &i32, &i32) + Send + 'static, ) -> UpdatePkI32CallbackId { - UpdatePkI32CallbackId(self.imp.on_reducer::( + UpdatePkI32CallbackId(self.imp.on_reducer( "update_pk_i32", - Box::new(move |ctx: &super::EventContext, args: &UpdatePkI32| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdatePkI32 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_pk_i_32(&self, callback: UpdatePkI32CallbackId) { - self.imp.remove_on_reducer::("update_pk_i32", callback.0) + self.imp.remove_on_reducer("update_pk_i32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_64_reducer.rs index 746c92a6ca0..4be4fd88740 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_64_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdatePkI64 { +pub(super) struct UpdatePkI64Args { pub n: i64, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdatePkI64 { +impl From for super::Reducer { + fn from(args: UpdatePkI64Args) -> Self { + Self::UpdatePkI64 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdatePkI64Args { type Module = super::RemoteModule; } -pub struct UpdatePkI64CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdatePkI64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_pk_i64`. @@ -53,19 +61,32 @@ pub trait update_pk_i_64 { impl update_pk_i_64 for super::RemoteReducers { fn update_pk_i_64(&self, n: i64, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_pk_i64", UpdatePkI64 { n, data }) + self.imp.call_reducer("update_pk_i64", UpdatePkI64Args { n, data }) } fn on_update_pk_i_64( &self, mut callback: impl FnMut(&super::EventContext, &i64, &i32) + Send + 'static, ) -> UpdatePkI64CallbackId { - UpdatePkI64CallbackId(self.imp.on_reducer::( + UpdatePkI64CallbackId(self.imp.on_reducer( "update_pk_i64", - Box::new(move |ctx: &super::EventContext, args: &UpdatePkI64| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdatePkI64 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_pk_i_64(&self, callback: UpdatePkI64CallbackId) { - self.imp.remove_on_reducer::("update_pk_i64", callback.0) + self.imp.remove_on_reducer("update_pk_i64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_8_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_8_reducer.rs index 5f145137717..30f8b2c9af7 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_8_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_pk_i_8_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdatePkI8 { +pub(super) struct UpdatePkI8Args { pub n: i8, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdatePkI8 { +impl From for super::Reducer { + fn from(args: UpdatePkI8Args) -> Self { + Self::UpdatePkI8 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdatePkI8Args { type Module = super::RemoteModule; } -pub struct UpdatePkI8CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdatePkI8CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_pk_i8`. @@ -53,19 +61,32 @@ pub trait update_pk_i_8 { impl update_pk_i_8 for super::RemoteReducers { fn update_pk_i_8(&self, n: i8, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_pk_i8", UpdatePkI8 { n, data }) + self.imp.call_reducer("update_pk_i8", UpdatePkI8Args { n, data }) } fn on_update_pk_i_8( &self, mut callback: impl FnMut(&super::EventContext, &i8, &i32) + Send + 'static, ) -> UpdatePkI8CallbackId { - UpdatePkI8CallbackId(self.imp.on_reducer::( + UpdatePkI8CallbackId(self.imp.on_reducer( "update_pk_i8", - Box::new(move |ctx: &super::EventContext, args: &UpdatePkI8| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdatePkI8 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_pk_i_8(&self, callback: UpdatePkI8CallbackId) { - self.imp.remove_on_reducer::("update_pk_i8", callback.0) + self.imp.remove_on_reducer("update_pk_i8", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_pk_identity_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_pk_identity_reducer.rs index 833e49a00de..2dfb59ddf16 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_pk_identity_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_pk_identity_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdatePkIdentity { +pub(super) struct UpdatePkIdentityArgs { pub i: __sdk::Identity, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdatePkIdentity { +impl From for super::Reducer { + fn from(args: UpdatePkIdentityArgs) -> Self { + Self::UpdatePkIdentity { + i: args.i, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdatePkIdentityArgs { type Module = super::RemoteModule; } -pub struct UpdatePkIdentityCallbackId(__sdk::callbacks::CallbackId); +pub struct UpdatePkIdentityCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_pk_identity`. @@ -54,20 +62,32 @@ pub trait update_pk_identity { impl update_pk_identity for super::RemoteReducers { fn update_pk_identity(&self, i: __sdk::Identity, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("update_pk_identity", UpdatePkIdentity { i, data }) + .call_reducer("update_pk_identity", UpdatePkIdentityArgs { i, data }) } fn on_update_pk_identity( &self, mut callback: impl FnMut(&super::EventContext, &__sdk::Identity, &i32) + Send + 'static, ) -> UpdatePkIdentityCallbackId { - UpdatePkIdentityCallbackId(self.imp.on_reducer::( + UpdatePkIdentityCallbackId(self.imp.on_reducer( "update_pk_identity", - Box::new(move |ctx: &super::EventContext, args: &UpdatePkIdentity| callback(ctx, &args.i, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdatePkIdentity { i, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, i, data) + }), )) } fn remove_on_update_pk_identity(&self, callback: UpdatePkIdentityCallbackId) { - self.imp - .remove_on_reducer::("update_pk_identity", callback.0) + self.imp.remove_on_reducer("update_pk_identity", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_pk_string_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_pk_string_reducer.rs index 66a3702b303..40820feb1b1 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_pk_string_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_pk_string_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdatePkString { +pub(super) struct UpdatePkStringArgs { pub s: String, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdatePkString { +impl From for super::Reducer { + fn from(args: UpdatePkStringArgs) -> Self { + Self::UpdatePkString { + s: args.s, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdatePkStringArgs { type Module = super::RemoteModule; } -pub struct UpdatePkStringCallbackId(__sdk::callbacks::CallbackId); +pub struct UpdatePkStringCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_pk_string`. @@ -53,20 +61,33 @@ pub trait update_pk_string { impl update_pk_string for super::RemoteReducers { fn update_pk_string(&self, s: String, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_pk_string", UpdatePkString { s, data }) + self.imp + .call_reducer("update_pk_string", UpdatePkStringArgs { s, data }) } fn on_update_pk_string( &self, mut callback: impl FnMut(&super::EventContext, &String, &i32) + Send + 'static, ) -> UpdatePkStringCallbackId { - UpdatePkStringCallbackId(self.imp.on_reducer::( + UpdatePkStringCallbackId(self.imp.on_reducer( "update_pk_string", - Box::new(move |ctx: &super::EventContext, args: &UpdatePkString| callback(ctx, &args.s, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdatePkString { s, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s, data) + }), )) } fn remove_on_update_pk_string(&self, callback: UpdatePkStringCallbackId) { - self.imp - .remove_on_reducer::("update_pk_string", callback.0) + self.imp.remove_on_reducer("update_pk_string", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_128_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_128_reducer.rs index e2458fe54a5..a8d7ef84f99 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_128_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_128_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdatePkU128 { +pub(super) struct UpdatePkU128Args { pub n: u128, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdatePkU128 { +impl From for super::Reducer { + fn from(args: UpdatePkU128Args) -> Self { + Self::UpdatePkU128 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdatePkU128Args { type Module = super::RemoteModule; } -pub struct UpdatePkU128CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdatePkU128CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_pk_u128`. @@ -53,19 +61,32 @@ pub trait update_pk_u_128 { impl update_pk_u_128 for super::RemoteReducers { fn update_pk_u_128(&self, n: u128, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_pk_u128", UpdatePkU128 { n, data }) + self.imp.call_reducer("update_pk_u128", UpdatePkU128Args { n, data }) } fn on_update_pk_u_128( &self, mut callback: impl FnMut(&super::EventContext, &u128, &i32) + Send + 'static, ) -> UpdatePkU128CallbackId { - UpdatePkU128CallbackId(self.imp.on_reducer::( + UpdatePkU128CallbackId(self.imp.on_reducer( "update_pk_u128", - Box::new(move |ctx: &super::EventContext, args: &UpdatePkU128| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdatePkU128 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_pk_u_128(&self, callback: UpdatePkU128CallbackId) { - self.imp.remove_on_reducer::("update_pk_u128", callback.0) + self.imp.remove_on_reducer("update_pk_u128", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_16_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_16_reducer.rs index 76ddd2a4f30..72a14537eba 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_16_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_16_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdatePkU16 { +pub(super) struct UpdatePkU16Args { pub n: u16, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdatePkU16 { +impl From for super::Reducer { + fn from(args: UpdatePkU16Args) -> Self { + Self::UpdatePkU16 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdatePkU16Args { type Module = super::RemoteModule; } -pub struct UpdatePkU16CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdatePkU16CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_pk_u16`. @@ -53,19 +61,32 @@ pub trait update_pk_u_16 { impl update_pk_u_16 for super::RemoteReducers { fn update_pk_u_16(&self, n: u16, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_pk_u16", UpdatePkU16 { n, data }) + self.imp.call_reducer("update_pk_u16", UpdatePkU16Args { n, data }) } fn on_update_pk_u_16( &self, mut callback: impl FnMut(&super::EventContext, &u16, &i32) + Send + 'static, ) -> UpdatePkU16CallbackId { - UpdatePkU16CallbackId(self.imp.on_reducer::( + UpdatePkU16CallbackId(self.imp.on_reducer( "update_pk_u16", - Box::new(move |ctx: &super::EventContext, args: &UpdatePkU16| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdatePkU16 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_pk_u_16(&self, callback: UpdatePkU16CallbackId) { - self.imp.remove_on_reducer::("update_pk_u16", callback.0) + self.imp.remove_on_reducer("update_pk_u16", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_256_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_256_reducer.rs index cc1fbc88f69..905c7e68057 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_256_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_256_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdatePkU256 { +pub(super) struct UpdatePkU256Args { pub n: __sats::u256, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdatePkU256 { +impl From for super::Reducer { + fn from(args: UpdatePkU256Args) -> Self { + Self::UpdatePkU256 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdatePkU256Args { type Module = super::RemoteModule; } -pub struct UpdatePkU256CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdatePkU256CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_pk_u256`. @@ -53,19 +61,32 @@ pub trait update_pk_u_256 { impl update_pk_u_256 for super::RemoteReducers { fn update_pk_u_256(&self, n: __sats::u256, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_pk_u256", UpdatePkU256 { n, data }) + self.imp.call_reducer("update_pk_u256", UpdatePkU256Args { n, data }) } fn on_update_pk_u_256( &self, mut callback: impl FnMut(&super::EventContext, &__sats::u256, &i32) + Send + 'static, ) -> UpdatePkU256CallbackId { - UpdatePkU256CallbackId(self.imp.on_reducer::( + UpdatePkU256CallbackId(self.imp.on_reducer( "update_pk_u256", - Box::new(move |ctx: &super::EventContext, args: &UpdatePkU256| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdatePkU256 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_pk_u_256(&self, callback: UpdatePkU256CallbackId) { - self.imp.remove_on_reducer::("update_pk_u256", callback.0) + self.imp.remove_on_reducer("update_pk_u256", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_32_reducer.rs index ea212b4b4ac..e79c0e15bbe 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_32_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdatePkU32 { +pub(super) struct UpdatePkU32Args { pub n: u32, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdatePkU32 { +impl From for super::Reducer { + fn from(args: UpdatePkU32Args) -> Self { + Self::UpdatePkU32 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdatePkU32Args { type Module = super::RemoteModule; } -pub struct UpdatePkU32CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdatePkU32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_pk_u32`. @@ -53,19 +61,32 @@ pub trait update_pk_u_32 { impl update_pk_u_32 for super::RemoteReducers { fn update_pk_u_32(&self, n: u32, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_pk_u32", UpdatePkU32 { n, data }) + self.imp.call_reducer("update_pk_u32", UpdatePkU32Args { n, data }) } fn on_update_pk_u_32( &self, mut callback: impl FnMut(&super::EventContext, &u32, &i32) + Send + 'static, ) -> UpdatePkU32CallbackId { - UpdatePkU32CallbackId(self.imp.on_reducer::( + UpdatePkU32CallbackId(self.imp.on_reducer( "update_pk_u32", - Box::new(move |ctx: &super::EventContext, args: &UpdatePkU32| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdatePkU32 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_pk_u_32(&self, callback: UpdatePkU32CallbackId) { - self.imp.remove_on_reducer::("update_pk_u32", callback.0) + self.imp.remove_on_reducer("update_pk_u32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_64_reducer.rs index b2325b21468..6ef11c0bf40 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_64_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdatePkU64 { +pub(super) struct UpdatePkU64Args { pub n: u64, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdatePkU64 { +impl From for super::Reducer { + fn from(args: UpdatePkU64Args) -> Self { + Self::UpdatePkU64 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdatePkU64Args { type Module = super::RemoteModule; } -pub struct UpdatePkU64CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdatePkU64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_pk_u64`. @@ -53,19 +61,32 @@ pub trait update_pk_u_64 { impl update_pk_u_64 for super::RemoteReducers { fn update_pk_u_64(&self, n: u64, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_pk_u64", UpdatePkU64 { n, data }) + self.imp.call_reducer("update_pk_u64", UpdatePkU64Args { n, data }) } fn on_update_pk_u_64( &self, mut callback: impl FnMut(&super::EventContext, &u64, &i32) + Send + 'static, ) -> UpdatePkU64CallbackId { - UpdatePkU64CallbackId(self.imp.on_reducer::( + UpdatePkU64CallbackId(self.imp.on_reducer( "update_pk_u64", - Box::new(move |ctx: &super::EventContext, args: &UpdatePkU64| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdatePkU64 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_pk_u_64(&self, callback: UpdatePkU64CallbackId) { - self.imp.remove_on_reducer::("update_pk_u64", callback.0) + self.imp.remove_on_reducer("update_pk_u64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_8_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_8_reducer.rs index 6654de8d585..5e3b4312960 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_8_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_pk_u_8_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdatePkU8 { +pub(super) struct UpdatePkU8Args { pub n: u8, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdatePkU8 { +impl From for super::Reducer { + fn from(args: UpdatePkU8Args) -> Self { + Self::UpdatePkU8 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdatePkU8Args { type Module = super::RemoteModule; } -pub struct UpdatePkU8CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdatePkU8CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_pk_u8`. @@ -53,19 +61,32 @@ pub trait update_pk_u_8 { impl update_pk_u_8 for super::RemoteReducers { fn update_pk_u_8(&self, n: u8, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_pk_u8", UpdatePkU8 { n, data }) + self.imp.call_reducer("update_pk_u8", UpdatePkU8Args { n, data }) } fn on_update_pk_u_8( &self, mut callback: impl FnMut(&super::EventContext, &u8, &i32) + Send + 'static, ) -> UpdatePkU8CallbackId { - UpdatePkU8CallbackId(self.imp.on_reducer::( + UpdatePkU8CallbackId(self.imp.on_reducer( "update_pk_u8", - Box::new(move |ctx: &super::EventContext, args: &UpdatePkU8| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdatePkU8 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_pk_u_8(&self, callback: UpdatePkU8CallbackId) { - self.imp.remove_on_reducer::("update_pk_u8", callback.0) + self.imp.remove_on_reducer("update_pk_u8", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_unique_address_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_unique_address_reducer.rs index bb1f61defb4..ed84ba30399 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_unique_address_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_unique_address_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdateUniqueAddress { +pub(super) struct UpdateUniqueAddressArgs { pub a: __sdk::Address, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdateUniqueAddress { +impl From for super::Reducer { + fn from(args: UpdateUniqueAddressArgs) -> Self { + Self::UpdateUniqueAddress { + a: args.a, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdateUniqueAddressArgs { type Module = super::RemoteModule; } -pub struct UpdateUniqueAddressCallbackId(__sdk::callbacks::CallbackId); +pub struct UpdateUniqueAddressCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_unique_address`. @@ -54,20 +62,32 @@ pub trait update_unique_address { impl update_unique_address for super::RemoteReducers { fn update_unique_address(&self, a: __sdk::Address, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("update_unique_address", UpdateUniqueAddress { a, data }) + .call_reducer("update_unique_address", UpdateUniqueAddressArgs { a, data }) } fn on_update_unique_address( &self, mut callback: impl FnMut(&super::EventContext, &__sdk::Address, &i32) + Send + 'static, ) -> UpdateUniqueAddressCallbackId { - UpdateUniqueAddressCallbackId(self.imp.on_reducer::( + UpdateUniqueAddressCallbackId(self.imp.on_reducer( "update_unique_address", - Box::new(move |ctx: &super::EventContext, args: &UpdateUniqueAddress| callback(ctx, &args.a, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdateUniqueAddress { a, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, a, data) + }), )) } fn remove_on_update_unique_address(&self, callback: UpdateUniqueAddressCallbackId) { - self.imp - .remove_on_reducer::("update_unique_address", callback.0) + self.imp.remove_on_reducer("update_unique_address", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_unique_bool_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_unique_bool_reducer.rs index 5b12f801635..f1442871c83 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_unique_bool_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_unique_bool_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdateUniqueBool { +pub(super) struct UpdateUniqueBoolArgs { pub b: bool, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdateUniqueBool { +impl From for super::Reducer { + fn from(args: UpdateUniqueBoolArgs) -> Self { + Self::UpdateUniqueBool { + b: args.b, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdateUniqueBoolArgs { type Module = super::RemoteModule; } -pub struct UpdateUniqueBoolCallbackId(__sdk::callbacks::CallbackId); +pub struct UpdateUniqueBoolCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_unique_bool`. @@ -54,20 +62,32 @@ pub trait update_unique_bool { impl update_unique_bool for super::RemoteReducers { fn update_unique_bool(&self, b: bool, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("update_unique_bool", UpdateUniqueBool { b, data }) + .call_reducer("update_unique_bool", UpdateUniqueBoolArgs { b, data }) } fn on_update_unique_bool( &self, mut callback: impl FnMut(&super::EventContext, &bool, &i32) + Send + 'static, ) -> UpdateUniqueBoolCallbackId { - UpdateUniqueBoolCallbackId(self.imp.on_reducer::( + UpdateUniqueBoolCallbackId(self.imp.on_reducer( "update_unique_bool", - Box::new(move |ctx: &super::EventContext, args: &UpdateUniqueBool| callback(ctx, &args.b, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdateUniqueBool { b, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, b, data) + }), )) } fn remove_on_update_unique_bool(&self, callback: UpdateUniqueBoolCallbackId) { - self.imp - .remove_on_reducer::("update_unique_bool", callback.0) + self.imp.remove_on_reducer("update_unique_bool", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_128_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_128_reducer.rs index 46295956068..5a4a8eb96e2 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_128_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_128_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdateUniqueI128 { +pub(super) struct UpdateUniqueI128Args { pub n: i128, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdateUniqueI128 { +impl From for super::Reducer { + fn from(args: UpdateUniqueI128Args) -> Self { + Self::UpdateUniqueI128 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdateUniqueI128Args { type Module = super::RemoteModule; } -pub struct UpdateUniqueI128CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdateUniqueI128CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_unique_i128`. @@ -54,20 +62,32 @@ pub trait update_unique_i_128 { impl update_unique_i_128 for super::RemoteReducers { fn update_unique_i_128(&self, n: i128, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("update_unique_i128", UpdateUniqueI128 { n, data }) + .call_reducer("update_unique_i128", UpdateUniqueI128Args { n, data }) } fn on_update_unique_i_128( &self, mut callback: impl FnMut(&super::EventContext, &i128, &i32) + Send + 'static, ) -> UpdateUniqueI128CallbackId { - UpdateUniqueI128CallbackId(self.imp.on_reducer::( + UpdateUniqueI128CallbackId(self.imp.on_reducer( "update_unique_i128", - Box::new(move |ctx: &super::EventContext, args: &UpdateUniqueI128| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdateUniqueI128 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_unique_i_128(&self, callback: UpdateUniqueI128CallbackId) { - self.imp - .remove_on_reducer::("update_unique_i128", callback.0) + self.imp.remove_on_reducer("update_unique_i128", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_16_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_16_reducer.rs index 55b96d25fb2..de08fc045cb 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_16_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_16_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdateUniqueI16 { +pub(super) struct UpdateUniqueI16Args { pub n: i16, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdateUniqueI16 { +impl From for super::Reducer { + fn from(args: UpdateUniqueI16Args) -> Self { + Self::UpdateUniqueI16 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdateUniqueI16Args { type Module = super::RemoteModule; } -pub struct UpdateUniqueI16CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdateUniqueI16CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_unique_i16`. @@ -53,20 +61,33 @@ pub trait update_unique_i_16 { impl update_unique_i_16 for super::RemoteReducers { fn update_unique_i_16(&self, n: i16, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_unique_i16", UpdateUniqueI16 { n, data }) + self.imp + .call_reducer("update_unique_i16", UpdateUniqueI16Args { n, data }) } fn on_update_unique_i_16( &self, mut callback: impl FnMut(&super::EventContext, &i16, &i32) + Send + 'static, ) -> UpdateUniqueI16CallbackId { - UpdateUniqueI16CallbackId(self.imp.on_reducer::( + UpdateUniqueI16CallbackId(self.imp.on_reducer( "update_unique_i16", - Box::new(move |ctx: &super::EventContext, args: &UpdateUniqueI16| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdateUniqueI16 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_unique_i_16(&self, callback: UpdateUniqueI16CallbackId) { - self.imp - .remove_on_reducer::("update_unique_i16", callback.0) + self.imp.remove_on_reducer("update_unique_i16", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_256_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_256_reducer.rs index c940a2aff8e..71995464c83 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_256_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_256_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdateUniqueI256 { +pub(super) struct UpdateUniqueI256Args { pub n: __sats::i256, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdateUniqueI256 { +impl From for super::Reducer { + fn from(args: UpdateUniqueI256Args) -> Self { + Self::UpdateUniqueI256 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdateUniqueI256Args { type Module = super::RemoteModule; } -pub struct UpdateUniqueI256CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdateUniqueI256CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_unique_i256`. @@ -54,20 +62,32 @@ pub trait update_unique_i_256 { impl update_unique_i_256 for super::RemoteReducers { fn update_unique_i_256(&self, n: __sats::i256, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("update_unique_i256", UpdateUniqueI256 { n, data }) + .call_reducer("update_unique_i256", UpdateUniqueI256Args { n, data }) } fn on_update_unique_i_256( &self, mut callback: impl FnMut(&super::EventContext, &__sats::i256, &i32) + Send + 'static, ) -> UpdateUniqueI256CallbackId { - UpdateUniqueI256CallbackId(self.imp.on_reducer::( + UpdateUniqueI256CallbackId(self.imp.on_reducer( "update_unique_i256", - Box::new(move |ctx: &super::EventContext, args: &UpdateUniqueI256| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdateUniqueI256 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_unique_i_256(&self, callback: UpdateUniqueI256CallbackId) { - self.imp - .remove_on_reducer::("update_unique_i256", callback.0) + self.imp.remove_on_reducer("update_unique_i256", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_32_reducer.rs index 25d960743e9..4c9adadb7e0 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_32_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdateUniqueI32 { +pub(super) struct UpdateUniqueI32Args { pub n: i32, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdateUniqueI32 { +impl From for super::Reducer { + fn from(args: UpdateUniqueI32Args) -> Self { + Self::UpdateUniqueI32 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdateUniqueI32Args { type Module = super::RemoteModule; } -pub struct UpdateUniqueI32CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdateUniqueI32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_unique_i32`. @@ -53,20 +61,33 @@ pub trait update_unique_i_32 { impl update_unique_i_32 for super::RemoteReducers { fn update_unique_i_32(&self, n: i32, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_unique_i32", UpdateUniqueI32 { n, data }) + self.imp + .call_reducer("update_unique_i32", UpdateUniqueI32Args { n, data }) } fn on_update_unique_i_32( &self, mut callback: impl FnMut(&super::EventContext, &i32, &i32) + Send + 'static, ) -> UpdateUniqueI32CallbackId { - UpdateUniqueI32CallbackId(self.imp.on_reducer::( + UpdateUniqueI32CallbackId(self.imp.on_reducer( "update_unique_i32", - Box::new(move |ctx: &super::EventContext, args: &UpdateUniqueI32| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdateUniqueI32 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_unique_i_32(&self, callback: UpdateUniqueI32CallbackId) { - self.imp - .remove_on_reducer::("update_unique_i32", callback.0) + self.imp.remove_on_reducer("update_unique_i32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_64_reducer.rs index 69e512b73db..b613e0cc825 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_64_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdateUniqueI64 { +pub(super) struct UpdateUniqueI64Args { pub n: i64, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdateUniqueI64 { +impl From for super::Reducer { + fn from(args: UpdateUniqueI64Args) -> Self { + Self::UpdateUniqueI64 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdateUniqueI64Args { type Module = super::RemoteModule; } -pub struct UpdateUniqueI64CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdateUniqueI64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_unique_i64`. @@ -53,20 +61,33 @@ pub trait update_unique_i_64 { impl update_unique_i_64 for super::RemoteReducers { fn update_unique_i_64(&self, n: i64, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_unique_i64", UpdateUniqueI64 { n, data }) + self.imp + .call_reducer("update_unique_i64", UpdateUniqueI64Args { n, data }) } fn on_update_unique_i_64( &self, mut callback: impl FnMut(&super::EventContext, &i64, &i32) + Send + 'static, ) -> UpdateUniqueI64CallbackId { - UpdateUniqueI64CallbackId(self.imp.on_reducer::( + UpdateUniqueI64CallbackId(self.imp.on_reducer( "update_unique_i64", - Box::new(move |ctx: &super::EventContext, args: &UpdateUniqueI64| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdateUniqueI64 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_unique_i_64(&self, callback: UpdateUniqueI64CallbackId) { - self.imp - .remove_on_reducer::("update_unique_i64", callback.0) + self.imp.remove_on_reducer("update_unique_i64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_8_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_8_reducer.rs index f113579e40b..8a46e220c42 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_8_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_unique_i_8_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdateUniqueI8 { +pub(super) struct UpdateUniqueI8Args { pub n: i8, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdateUniqueI8 { +impl From for super::Reducer { + fn from(args: UpdateUniqueI8Args) -> Self { + Self::UpdateUniqueI8 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdateUniqueI8Args { type Module = super::RemoteModule; } -pub struct UpdateUniqueI8CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdateUniqueI8CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_unique_i8`. @@ -53,20 +61,33 @@ pub trait update_unique_i_8 { impl update_unique_i_8 for super::RemoteReducers { fn update_unique_i_8(&self, n: i8, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_unique_i8", UpdateUniqueI8 { n, data }) + self.imp + .call_reducer("update_unique_i8", UpdateUniqueI8Args { n, data }) } fn on_update_unique_i_8( &self, mut callback: impl FnMut(&super::EventContext, &i8, &i32) + Send + 'static, ) -> UpdateUniqueI8CallbackId { - UpdateUniqueI8CallbackId(self.imp.on_reducer::( + UpdateUniqueI8CallbackId(self.imp.on_reducer( "update_unique_i8", - Box::new(move |ctx: &super::EventContext, args: &UpdateUniqueI8| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdateUniqueI8 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_unique_i_8(&self, callback: UpdateUniqueI8CallbackId) { - self.imp - .remove_on_reducer::("update_unique_i8", callback.0) + self.imp.remove_on_reducer("update_unique_i8", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_unique_identity_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_unique_identity_reducer.rs index 4c0e9b403f4..061fb35f5a1 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_unique_identity_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_unique_identity_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdateUniqueIdentity { +pub(super) struct UpdateUniqueIdentityArgs { pub i: __sdk::Identity, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdateUniqueIdentity { +impl From for super::Reducer { + fn from(args: UpdateUniqueIdentityArgs) -> Self { + Self::UpdateUniqueIdentity { + i: args.i, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdateUniqueIdentityArgs { type Module = super::RemoteModule; } -pub struct UpdateUniqueIdentityCallbackId(__sdk::callbacks::CallbackId); +pub struct UpdateUniqueIdentityCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_unique_identity`. @@ -54,20 +62,32 @@ pub trait update_unique_identity { impl update_unique_identity for super::RemoteReducers { fn update_unique_identity(&self, i: __sdk::Identity, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("update_unique_identity", UpdateUniqueIdentity { i, data }) + .call_reducer("update_unique_identity", UpdateUniqueIdentityArgs { i, data }) } fn on_update_unique_identity( &self, mut callback: impl FnMut(&super::EventContext, &__sdk::Identity, &i32) + Send + 'static, ) -> UpdateUniqueIdentityCallbackId { - UpdateUniqueIdentityCallbackId(self.imp.on_reducer::( + UpdateUniqueIdentityCallbackId(self.imp.on_reducer( "update_unique_identity", - Box::new(move |ctx: &super::EventContext, args: &UpdateUniqueIdentity| callback(ctx, &args.i, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdateUniqueIdentity { i, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, i, data) + }), )) } fn remove_on_update_unique_identity(&self, callback: UpdateUniqueIdentityCallbackId) { - self.imp - .remove_on_reducer::("update_unique_identity", callback.0) + self.imp.remove_on_reducer("update_unique_identity", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_unique_string_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_unique_string_reducer.rs index 7de7b54e867..9b40a076428 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_unique_string_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_unique_string_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdateUniqueString { +pub(super) struct UpdateUniqueStringArgs { pub s: String, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdateUniqueString { +impl From for super::Reducer { + fn from(args: UpdateUniqueStringArgs) -> Self { + Self::UpdateUniqueString { + s: args.s, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdateUniqueStringArgs { type Module = super::RemoteModule; } -pub struct UpdateUniqueStringCallbackId(__sdk::callbacks::CallbackId); +pub struct UpdateUniqueStringCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_unique_string`. @@ -54,20 +62,32 @@ pub trait update_unique_string { impl update_unique_string for super::RemoteReducers { fn update_unique_string(&self, s: String, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("update_unique_string", UpdateUniqueString { s, data }) + .call_reducer("update_unique_string", UpdateUniqueStringArgs { s, data }) } fn on_update_unique_string( &self, mut callback: impl FnMut(&super::EventContext, &String, &i32) + Send + 'static, ) -> UpdateUniqueStringCallbackId { - UpdateUniqueStringCallbackId(self.imp.on_reducer::( + UpdateUniqueStringCallbackId(self.imp.on_reducer( "update_unique_string", - Box::new(move |ctx: &super::EventContext, args: &UpdateUniqueString| callback(ctx, &args.s, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdateUniqueString { s, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, s, data) + }), )) } fn remove_on_update_unique_string(&self, callback: UpdateUniqueStringCallbackId) { - self.imp - .remove_on_reducer::("update_unique_string", callback.0) + self.imp.remove_on_reducer("update_unique_string", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_128_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_128_reducer.rs index e3bfb08dd7d..a496503611d 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_128_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_128_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdateUniqueU128 { +pub(super) struct UpdateUniqueU128Args { pub n: u128, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdateUniqueU128 { +impl From for super::Reducer { + fn from(args: UpdateUniqueU128Args) -> Self { + Self::UpdateUniqueU128 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdateUniqueU128Args { type Module = super::RemoteModule; } -pub struct UpdateUniqueU128CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdateUniqueU128CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_unique_u128`. @@ -54,20 +62,32 @@ pub trait update_unique_u_128 { impl update_unique_u_128 for super::RemoteReducers { fn update_unique_u_128(&self, n: u128, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("update_unique_u128", UpdateUniqueU128 { n, data }) + .call_reducer("update_unique_u128", UpdateUniqueU128Args { n, data }) } fn on_update_unique_u_128( &self, mut callback: impl FnMut(&super::EventContext, &u128, &i32) + Send + 'static, ) -> UpdateUniqueU128CallbackId { - UpdateUniqueU128CallbackId(self.imp.on_reducer::( + UpdateUniqueU128CallbackId(self.imp.on_reducer( "update_unique_u128", - Box::new(move |ctx: &super::EventContext, args: &UpdateUniqueU128| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdateUniqueU128 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_unique_u_128(&self, callback: UpdateUniqueU128CallbackId) { - self.imp - .remove_on_reducer::("update_unique_u128", callback.0) + self.imp.remove_on_reducer("update_unique_u128", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_16_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_16_reducer.rs index 117f96a7fc5..95ee1632663 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_16_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_16_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdateUniqueU16 { +pub(super) struct UpdateUniqueU16Args { pub n: u16, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdateUniqueU16 { +impl From for super::Reducer { + fn from(args: UpdateUniqueU16Args) -> Self { + Self::UpdateUniqueU16 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdateUniqueU16Args { type Module = super::RemoteModule; } -pub struct UpdateUniqueU16CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdateUniqueU16CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_unique_u16`. @@ -53,20 +61,33 @@ pub trait update_unique_u_16 { impl update_unique_u_16 for super::RemoteReducers { fn update_unique_u_16(&self, n: u16, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_unique_u16", UpdateUniqueU16 { n, data }) + self.imp + .call_reducer("update_unique_u16", UpdateUniqueU16Args { n, data }) } fn on_update_unique_u_16( &self, mut callback: impl FnMut(&super::EventContext, &u16, &i32) + Send + 'static, ) -> UpdateUniqueU16CallbackId { - UpdateUniqueU16CallbackId(self.imp.on_reducer::( + UpdateUniqueU16CallbackId(self.imp.on_reducer( "update_unique_u16", - Box::new(move |ctx: &super::EventContext, args: &UpdateUniqueU16| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdateUniqueU16 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_unique_u_16(&self, callback: UpdateUniqueU16CallbackId) { - self.imp - .remove_on_reducer::("update_unique_u16", callback.0) + self.imp.remove_on_reducer("update_unique_u16", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_256_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_256_reducer.rs index b3194175dd3..83955990a9c 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_256_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_256_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdateUniqueU256 { +pub(super) struct UpdateUniqueU256Args { pub n: __sats::u256, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdateUniqueU256 { +impl From for super::Reducer { + fn from(args: UpdateUniqueU256Args) -> Self { + Self::UpdateUniqueU256 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdateUniqueU256Args { type Module = super::RemoteModule; } -pub struct UpdateUniqueU256CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdateUniqueU256CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_unique_u256`. @@ -54,20 +62,32 @@ pub trait update_unique_u_256 { impl update_unique_u_256 for super::RemoteReducers { fn update_unique_u_256(&self, n: __sats::u256, data: i32) -> __anyhow::Result<()> { self.imp - .call_reducer("update_unique_u256", UpdateUniqueU256 { n, data }) + .call_reducer("update_unique_u256", UpdateUniqueU256Args { n, data }) } fn on_update_unique_u_256( &self, mut callback: impl FnMut(&super::EventContext, &__sats::u256, &i32) + Send + 'static, ) -> UpdateUniqueU256CallbackId { - UpdateUniqueU256CallbackId(self.imp.on_reducer::( + UpdateUniqueU256CallbackId(self.imp.on_reducer( "update_unique_u256", - Box::new(move |ctx: &super::EventContext, args: &UpdateUniqueU256| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdateUniqueU256 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_unique_u_256(&self, callback: UpdateUniqueU256CallbackId) { - self.imp - .remove_on_reducer::("update_unique_u256", callback.0) + self.imp.remove_on_reducer("update_unique_u256", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_32_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_32_reducer.rs index 8eb5b3bd4bb..a4ea2d15dd5 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_32_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_32_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdateUniqueU32 { +pub(super) struct UpdateUniqueU32Args { pub n: u32, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdateUniqueU32 { +impl From for super::Reducer { + fn from(args: UpdateUniqueU32Args) -> Self { + Self::UpdateUniqueU32 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdateUniqueU32Args { type Module = super::RemoteModule; } -pub struct UpdateUniqueU32CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdateUniqueU32CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_unique_u32`. @@ -53,20 +61,33 @@ pub trait update_unique_u_32 { impl update_unique_u_32 for super::RemoteReducers { fn update_unique_u_32(&self, n: u32, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_unique_u32", UpdateUniqueU32 { n, data }) + self.imp + .call_reducer("update_unique_u32", UpdateUniqueU32Args { n, data }) } fn on_update_unique_u_32( &self, mut callback: impl FnMut(&super::EventContext, &u32, &i32) + Send + 'static, ) -> UpdateUniqueU32CallbackId { - UpdateUniqueU32CallbackId(self.imp.on_reducer::( + UpdateUniqueU32CallbackId(self.imp.on_reducer( "update_unique_u32", - Box::new(move |ctx: &super::EventContext, args: &UpdateUniqueU32| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdateUniqueU32 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_unique_u_32(&self, callback: UpdateUniqueU32CallbackId) { - self.imp - .remove_on_reducer::("update_unique_u32", callback.0) + self.imp.remove_on_reducer("update_unique_u32", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_64_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_64_reducer.rs index 7d4fe9211f0..8b0b03358c3 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_64_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_64_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdateUniqueU64 { +pub(super) struct UpdateUniqueU64Args { pub n: u64, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdateUniqueU64 { +impl From for super::Reducer { + fn from(args: UpdateUniqueU64Args) -> Self { + Self::UpdateUniqueU64 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdateUniqueU64Args { type Module = super::RemoteModule; } -pub struct UpdateUniqueU64CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdateUniqueU64CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_unique_u64`. @@ -53,20 +61,33 @@ pub trait update_unique_u_64 { impl update_unique_u_64 for super::RemoteReducers { fn update_unique_u_64(&self, n: u64, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_unique_u64", UpdateUniqueU64 { n, data }) + self.imp + .call_reducer("update_unique_u64", UpdateUniqueU64Args { n, data }) } fn on_update_unique_u_64( &self, mut callback: impl FnMut(&super::EventContext, &u64, &i32) + Send + 'static, ) -> UpdateUniqueU64CallbackId { - UpdateUniqueU64CallbackId(self.imp.on_reducer::( + UpdateUniqueU64CallbackId(self.imp.on_reducer( "update_unique_u64", - Box::new(move |ctx: &super::EventContext, args: &UpdateUniqueU64| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdateUniqueU64 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_unique_u_64(&self, callback: UpdateUniqueU64CallbackId) { - self.imp - .remove_on_reducer::("update_unique_u64", callback.0) + self.imp.remove_on_reducer("update_unique_u64", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_8_reducer.rs b/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_8_reducer.rs index cc5fd6db16b..72e86064f09 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_8_reducer.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/update_unique_u_8_reducer.rs @@ -2,24 +2,32 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct UpdateUniqueU8 { +pub(super) struct UpdateUniqueU8Args { pub n: u8, pub data: i32, } -impl __sdk::spacetime_module::InModule for UpdateUniqueU8 { +impl From for super::Reducer { + fn from(args: UpdateUniqueU8Args) -> Self { + Self::UpdateUniqueU8 { + n: args.n, + data: args.data, + } + } +} + +impl __sdk::InModule for UpdateUniqueU8Args { type Module = super::RemoteModule; } -pub struct UpdateUniqueU8CallbackId(__sdk::callbacks::CallbackId); +pub struct UpdateUniqueU8CallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] /// Extension trait for access to the reducer `update_unique_u8`. @@ -53,20 +61,33 @@ pub trait update_unique_u_8 { impl update_unique_u_8 for super::RemoteReducers { fn update_unique_u_8(&self, n: u8, data: i32) -> __anyhow::Result<()> { - self.imp.call_reducer("update_unique_u8", UpdateUniqueU8 { n, data }) + self.imp + .call_reducer("update_unique_u8", UpdateUniqueU8Args { n, data }) } fn on_update_unique_u_8( &self, mut callback: impl FnMut(&super::EventContext, &u8, &i32) + Send + 'static, ) -> UpdateUniqueU8CallbackId { - UpdateUniqueU8CallbackId(self.imp.on_reducer::( + UpdateUniqueU8CallbackId(self.imp.on_reducer( "update_unique_u8", - Box::new(move |ctx: &super::EventContext, args: &UpdateUniqueU8| callback(ctx, &args.n, &args.data)), + Box::new(move |ctx: &super::EventContext| { + let super::EventContext { + event: + __sdk::Event::Reducer(__sdk::ReducerEvent { + reducer: super::Reducer::UpdateUniqueU8 { n, data }, + .. + }), + .. + } = ctx + else { + unreachable!() + }; + callback(ctx, n, data) + }), )) } fn remove_on_update_unique_u_8(&self, callback: UpdateUniqueU8CallbackId) { - self.imp - .remove_on_reducer::("update_unique_u8", callback.0) + self.imp.remove_on_reducer("update_unique_u8", callback.0) } } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_address_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_address_table.rs index da1bceb6827..fce82472956 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_address_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_address_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_address_type::VecAddress; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_address`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_address().on_insert(...)`. pub struct VecAddressTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecAddressTableAccess for super::RemoteTables { } } -pub struct VecAddressInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecAddressDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecAddressInsertCallbackId(__sdk::CallbackId); +pub struct VecAddressDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecAddressTableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecAddressTableHandle<'ctx> { type Row = VecAddress; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecAddressTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_address"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_address\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_address_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_address_type.rs index 08c75d01da8..a898da1fdb5 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_address_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_address_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecAddress { pub a: Vec<__sdk::Address>, } -impl __sdk::spacetime_module::InModule for VecAddress { +impl __sdk::InModule for VecAddress { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_bool_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_bool_table.rs index 8f659d02195..bb598ca4ac4 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_bool_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_bool_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_bool_type::VecBool; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_bool`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_bool().on_insert(...)`. pub struct VecBoolTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecBoolTableAccess for super::RemoteTables { } } -pub struct VecBoolInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecBoolDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecBoolInsertCallbackId(__sdk::CallbackId); +pub struct VecBoolDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecBoolTableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecBoolTableHandle<'ctx> { type Row = VecBool; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecBoolTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_bool"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_bool\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_bool_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_bool_type.rs index bf0beed37de..bd5c95f0cc6 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_bool_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_bool_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecBool { pub b: Vec, } -impl __sdk::spacetime_module::InModule for VecBool { +impl __sdk::InModule for VecBool { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_byte_struct_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_byte_struct_table.rs index fe6369b9d91..38322d721f7 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_byte_struct_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_byte_struct_table.rs @@ -4,10 +4,9 @@ #![allow(unused)] use super::byte_struct_type::ByteStruct; use super::vec_byte_struct_type::VecByteStruct; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_byte_struct`. @@ -19,7 +18,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_byte_struct().on_insert(...)`. pub struct VecByteStructTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -42,10 +41,10 @@ impl VecByteStructTableAccess for super::RemoteTables { } } -pub struct VecByteStructInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecByteStructDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecByteStructInsertCallbackId(__sdk::CallbackId); +pub struct VecByteStructDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecByteStructTableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecByteStructTableHandle<'ctx> { type Row = VecByteStruct; type EventContext = super::EventContext; @@ -83,10 +82,14 @@ impl<'ctx> __sdk::table::Table for VecByteStructTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_byte_struct"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_byte_struct\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_byte_struct_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_byte_struct_type.rs index 7905b18c424..d0e5f577e05 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_byte_struct_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_byte_struct_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::byte_struct_type::ByteStruct; @@ -16,6 +15,6 @@ pub struct VecByteStruct { pub s: Vec, } -impl __sdk::spacetime_module::InModule for VecByteStruct { +impl __sdk::InModule for VecByteStruct { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_enum_with_payload_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_enum_with_payload_table.rs index c656c228bbd..0e4448eaca2 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_enum_with_payload_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_enum_with_payload_table.rs @@ -4,10 +4,9 @@ #![allow(unused)] use super::enum_with_payload_type::EnumWithPayload; use super::vec_enum_with_payload_type::VecEnumWithPayload; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_enum_with_payload`. @@ -19,7 +18,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_enum_with_payload().on_insert(...)`. pub struct VecEnumWithPayloadTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -42,10 +41,10 @@ impl VecEnumWithPayloadTableAccess for super::RemoteTables { } } -pub struct VecEnumWithPayloadInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecEnumWithPayloadDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecEnumWithPayloadInsertCallbackId(__sdk::CallbackId); +pub struct VecEnumWithPayloadDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecEnumWithPayloadTableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecEnumWithPayloadTableHandle<'ctx> { type Row = VecEnumWithPayload; type EventContext = super::EventContext; @@ -83,10 +82,14 @@ impl<'ctx> __sdk::table::Table for VecEnumWithPayloadTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_enum_with_payload"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_enum_with_payload\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_enum_with_payload_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_enum_with_payload_type.rs index 1577a40bf6d..007080db669 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_enum_with_payload_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_enum_with_payload_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::enum_with_payload_type::EnumWithPayload; @@ -16,6 +15,6 @@ pub struct VecEnumWithPayload { pub e: Vec, } -impl __sdk::spacetime_module::InModule for VecEnumWithPayload { +impl __sdk::InModule for VecEnumWithPayload { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_every_primitive_struct_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_every_primitive_struct_table.rs index 1f9bcae583d..f07a303f9c1 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_every_primitive_struct_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_every_primitive_struct_table.rs @@ -4,10 +4,9 @@ #![allow(unused)] use super::every_primitive_struct_type::EveryPrimitiveStruct; use super::vec_every_primitive_struct_type::VecEveryPrimitiveStruct; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_every_primitive_struct`. @@ -19,7 +18,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_every_primitive_struct().on_insert(...)`. pub struct VecEveryPrimitiveStructTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -44,10 +43,10 @@ impl VecEveryPrimitiveStructTableAccess for super::RemoteTables { } } -pub struct VecEveryPrimitiveStructInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecEveryPrimitiveStructDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecEveryPrimitiveStructInsertCallbackId(__sdk::CallbackId); +pub struct VecEveryPrimitiveStructDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecEveryPrimitiveStructTableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecEveryPrimitiveStructTableHandle<'ctx> { type Row = VecEveryPrimitiveStruct; type EventContext = super::EventContext; @@ -85,10 +84,14 @@ impl<'ctx> __sdk::table::Table for VecEveryPrimitiveStructTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_every_primitive_struct"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_every_primitive_struct\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_every_primitive_struct_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_every_primitive_struct_type.rs index 3ccb4097335..fa66a5f52b7 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_every_primitive_struct_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_every_primitive_struct_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::every_primitive_struct_type::EveryPrimitiveStruct; @@ -16,6 +15,6 @@ pub struct VecEveryPrimitiveStruct { pub s: Vec, } -impl __sdk::spacetime_module::InModule for VecEveryPrimitiveStruct { +impl __sdk::InModule for VecEveryPrimitiveStruct { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_every_vec_struct_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_every_vec_struct_table.rs index f30c45bff34..3da938ec649 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_every_vec_struct_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_every_vec_struct_table.rs @@ -4,10 +4,9 @@ #![allow(unused)] use super::every_vec_struct_type::EveryVecStruct; use super::vec_every_vec_struct_type::VecEveryVecStruct; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_every_vec_struct`. @@ -19,7 +18,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_every_vec_struct().on_insert(...)`. pub struct VecEveryVecStructTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -42,10 +41,10 @@ impl VecEveryVecStructTableAccess for super::RemoteTables { } } -pub struct VecEveryVecStructInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecEveryVecStructDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecEveryVecStructInsertCallbackId(__sdk::CallbackId); +pub struct VecEveryVecStructDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecEveryVecStructTableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecEveryVecStructTableHandle<'ctx> { type Row = VecEveryVecStruct; type EventContext = super::EventContext; @@ -83,10 +82,14 @@ impl<'ctx> __sdk::table::Table for VecEveryVecStructTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_every_vec_struct"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_every_vec_struct\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_every_vec_struct_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_every_vec_struct_type.rs index 10f71d1ed9d..4d67156c8de 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_every_vec_struct_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_every_vec_struct_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::every_vec_struct_type::EveryVecStruct; @@ -16,6 +15,6 @@ pub struct VecEveryVecStruct { pub s: Vec, } -impl __sdk::spacetime_module::InModule for VecEveryVecStruct { +impl __sdk::InModule for VecEveryVecStruct { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_f_32_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_f_32_table.rs index 4eb4fe87054..136933a8e0c 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_f_32_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_f_32_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_f_32_type::VecF32; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_f32`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_f_32().on_insert(...)`. pub struct VecF32TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecF32TableAccess for super::RemoteTables { } } -pub struct VecF32InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecF32DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecF32InsertCallbackId(__sdk::CallbackId); +pub struct VecF32DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecF32TableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecF32TableHandle<'ctx> { type Row = VecF32; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecF32TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_f32"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_f32\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_f_32_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_f_32_type.rs index ae11a24b8e6..ba50c502d5d 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_f_32_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_f_32_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecF32 { pub f: Vec, } -impl __sdk::spacetime_module::InModule for VecF32 { +impl __sdk::InModule for VecF32 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_f_64_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_f_64_table.rs index 838573c5018..0133dd1144c 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_f_64_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_f_64_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_f_64_type::VecF64; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_f64`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_f_64().on_insert(...)`. pub struct VecF64TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecF64TableAccess for super::RemoteTables { } } -pub struct VecF64InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecF64DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecF64InsertCallbackId(__sdk::CallbackId); +pub struct VecF64DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecF64TableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecF64TableHandle<'ctx> { type Row = VecF64; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecF64TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_f64"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_f64\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_f_64_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_f_64_type.rs index 68b0efb1b60..a22969a2ea2 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_f_64_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_f_64_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecF64 { pub f: Vec, } -impl __sdk::spacetime_module::InModule for VecF64 { +impl __sdk::InModule for VecF64 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_i_128_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_i_128_table.rs index dc16bc1b95e..869df0b712f 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_i_128_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_i_128_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_i_128_type::VecI128; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_i128`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_i_128().on_insert(...)`. pub struct VecI128TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecI128TableAccess for super::RemoteTables { } } -pub struct VecI128InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecI128DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecI128InsertCallbackId(__sdk::CallbackId); +pub struct VecI128DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecI128TableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecI128TableHandle<'ctx> { type Row = VecI128; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecI128TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_i128"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_i128\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_i_128_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_i_128_type.rs index c184ae28824..7708a022e54 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_i_128_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_i_128_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecI128 { pub n: Vec, } -impl __sdk::spacetime_module::InModule for VecI128 { +impl __sdk::InModule for VecI128 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_i_16_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_i_16_table.rs index b152c36eec3..0f163d98720 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_i_16_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_i_16_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_i_16_type::VecI16; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_i16`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_i_16().on_insert(...)`. pub struct VecI16TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecI16TableAccess for super::RemoteTables { } } -pub struct VecI16InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecI16DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecI16InsertCallbackId(__sdk::CallbackId); +pub struct VecI16DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecI16TableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecI16TableHandle<'ctx> { type Row = VecI16; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecI16TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_i16"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_i16\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_i_16_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_i_16_type.rs index 1fe62f1f9e8..9ce0f6ad1a7 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_i_16_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_i_16_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecI16 { pub n: Vec, } -impl __sdk::spacetime_module::InModule for VecI16 { +impl __sdk::InModule for VecI16 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_i_256_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_i_256_table.rs index 30e32027363..abc9bcf4506 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_i_256_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_i_256_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_i_256_type::VecI256; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_i256`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_i_256().on_insert(...)`. pub struct VecI256TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecI256TableAccess for super::RemoteTables { } } -pub struct VecI256InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecI256DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecI256InsertCallbackId(__sdk::CallbackId); +pub struct VecI256DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecI256TableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecI256TableHandle<'ctx> { type Row = VecI256; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecI256TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_i256"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_i256\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_i_256_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_i_256_type.rs index 692b45ea906..51dd1f313c8 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_i_256_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_i_256_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecI256 { pub n: Vec<__sats::i256>, } -impl __sdk::spacetime_module::InModule for VecI256 { +impl __sdk::InModule for VecI256 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_i_32_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_i_32_table.rs index 0f091dbc77e..6fe76034943 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_i_32_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_i_32_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_i_32_type::VecI32; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_i32`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_i_32().on_insert(...)`. pub struct VecI32TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecI32TableAccess for super::RemoteTables { } } -pub struct VecI32InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecI32DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecI32InsertCallbackId(__sdk::CallbackId); +pub struct VecI32DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecI32TableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecI32TableHandle<'ctx> { type Row = VecI32; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecI32TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_i32"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_i32\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_i_32_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_i_32_type.rs index 04b91751b49..2001ebc9941 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_i_32_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_i_32_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecI32 { pub n: Vec, } -impl __sdk::spacetime_module::InModule for VecI32 { +impl __sdk::InModule for VecI32 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_i_64_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_i_64_table.rs index b165fa68c8a..8a4c0c02b9a 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_i_64_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_i_64_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_i_64_type::VecI64; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_i64`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_i_64().on_insert(...)`. pub struct VecI64TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecI64TableAccess for super::RemoteTables { } } -pub struct VecI64InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecI64DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecI64InsertCallbackId(__sdk::CallbackId); +pub struct VecI64DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecI64TableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecI64TableHandle<'ctx> { type Row = VecI64; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecI64TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_i64"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_i64\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_i_64_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_i_64_type.rs index 31ba9d3a07d..bb280358756 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_i_64_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_i_64_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecI64 { pub n: Vec, } -impl __sdk::spacetime_module::InModule for VecI64 { +impl __sdk::InModule for VecI64 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_i_8_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_i_8_table.rs index 15e8abf384b..0358c8127f7 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_i_8_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_i_8_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_i_8_type::VecI8; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_i8`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_i_8().on_insert(...)`. pub struct VecI8TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecI8TableAccess for super::RemoteTables { } } -pub struct VecI8InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecI8DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecI8InsertCallbackId(__sdk::CallbackId); +pub struct VecI8DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecI8TableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecI8TableHandle<'ctx> { type Row = VecI8; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecI8TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_i8"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_i8\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_i_8_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_i_8_type.rs index 3b7a073688b..219d5bb0424 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_i_8_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_i_8_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecI8 { pub n: Vec, } -impl __sdk::spacetime_module::InModule for VecI8 { +impl __sdk::InModule for VecI8 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_identity_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_identity_table.rs index 5e1828b30f1..507143242fa 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_identity_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_identity_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_identity_type::VecIdentity; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_identity`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_identity().on_insert(...)`. pub struct VecIdentityTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecIdentityTableAccess for super::RemoteTables { } } -pub struct VecIdentityInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecIdentityDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecIdentityInsertCallbackId(__sdk::CallbackId); +pub struct VecIdentityDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecIdentityTableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecIdentityTableHandle<'ctx> { type Row = VecIdentity; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecIdentityTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_identity"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_identity\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_identity_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_identity_type.rs index 90ac2bc1eb5..231b33c1147 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_identity_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_identity_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecIdentity { pub i: Vec<__sdk::Identity>, } -impl __sdk::spacetime_module::InModule for VecIdentity { +impl __sdk::InModule for VecIdentity { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_simple_enum_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_simple_enum_table.rs index 8c35332e50e..13b3545780b 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_simple_enum_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_simple_enum_table.rs @@ -4,10 +4,9 @@ #![allow(unused)] use super::simple_enum_type::SimpleEnum; use super::vec_simple_enum_type::VecSimpleEnum; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_simple_enum`. @@ -19,7 +18,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_simple_enum().on_insert(...)`. pub struct VecSimpleEnumTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -42,10 +41,10 @@ impl VecSimpleEnumTableAccess for super::RemoteTables { } } -pub struct VecSimpleEnumInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecSimpleEnumDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecSimpleEnumInsertCallbackId(__sdk::CallbackId); +pub struct VecSimpleEnumDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecSimpleEnumTableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecSimpleEnumTableHandle<'ctx> { type Row = VecSimpleEnum; type EventContext = super::EventContext; @@ -83,10 +82,14 @@ impl<'ctx> __sdk::table::Table for VecSimpleEnumTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_simple_enum"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_simple_enum\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_simple_enum_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_simple_enum_type.rs index ad844c78739..c6b5b6ec6c1 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_simple_enum_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_simple_enum_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::simple_enum_type::SimpleEnum; @@ -16,6 +15,6 @@ pub struct VecSimpleEnum { pub e: Vec, } -impl __sdk::spacetime_module::InModule for VecSimpleEnum { +impl __sdk::InModule for VecSimpleEnum { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_string_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_string_table.rs index 42842147191..89506a5bce5 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_string_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_string_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_string_type::VecString; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_string`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_string().on_insert(...)`. pub struct VecStringTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecStringTableAccess for super::RemoteTables { } } -pub struct VecStringInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecStringDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecStringInsertCallbackId(__sdk::CallbackId); +pub struct VecStringDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecStringTableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecStringTableHandle<'ctx> { type Row = VecString; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecStringTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_string"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_string\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_string_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_string_type.rs index 1cd315ee3b3..33b69ff9fb1 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_string_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_string_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecString { pub s: Vec, } -impl __sdk::spacetime_module::InModule for VecString { +impl __sdk::InModule for VecString { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_u_128_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_u_128_table.rs index 867532ef356..6dc83e5abcf 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_u_128_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_u_128_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_u_128_type::VecU128; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_u128`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_u_128().on_insert(...)`. pub struct VecU128TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecU128TableAccess for super::RemoteTables { } } -pub struct VecU128InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecU128DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecU128InsertCallbackId(__sdk::CallbackId); +pub struct VecU128DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecU128TableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecU128TableHandle<'ctx> { type Row = VecU128; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecU128TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_u128"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_u128\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_u_128_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_u_128_type.rs index 0c4beef3a1c..7d2df7a2395 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_u_128_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_u_128_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecU128 { pub n: Vec, } -impl __sdk::spacetime_module::InModule for VecU128 { +impl __sdk::InModule for VecU128 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_u_16_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_u_16_table.rs index 7c4ace51e70..7efdd5f830a 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_u_16_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_u_16_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_u_16_type::VecU16; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_u16`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_u_16().on_insert(...)`. pub struct VecU16TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecU16TableAccess for super::RemoteTables { } } -pub struct VecU16InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecU16DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecU16InsertCallbackId(__sdk::CallbackId); +pub struct VecU16DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecU16TableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecU16TableHandle<'ctx> { type Row = VecU16; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecU16TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_u16"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_u16\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_u_16_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_u_16_type.rs index 4215b941971..0f6f888d7db 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_u_16_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_u_16_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecU16 { pub n: Vec, } -impl __sdk::spacetime_module::InModule for VecU16 { +impl __sdk::InModule for VecU16 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_u_256_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_u_256_table.rs index 368682740be..36779ebf3bf 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_u_256_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_u_256_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_u_256_type::VecU256; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_u256`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_u_256().on_insert(...)`. pub struct VecU256TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecU256TableAccess for super::RemoteTables { } } -pub struct VecU256InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecU256DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecU256InsertCallbackId(__sdk::CallbackId); +pub struct VecU256DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecU256TableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecU256TableHandle<'ctx> { type Row = VecU256; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecU256TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_u256"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_u256\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_u_256_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_u_256_type.rs index 51bbcdfae57..b7c0ce5b351 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_u_256_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_u_256_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecU256 { pub n: Vec<__sats::u256>, } -impl __sdk::spacetime_module::InModule for VecU256 { +impl __sdk::InModule for VecU256 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_u_32_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_u_32_table.rs index 4777a2271b2..74bf11f69c1 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_u_32_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_u_32_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_u_32_type::VecU32; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_u32`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_u_32().on_insert(...)`. pub struct VecU32TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecU32TableAccess for super::RemoteTables { } } -pub struct VecU32InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecU32DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecU32InsertCallbackId(__sdk::CallbackId); +pub struct VecU32DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecU32TableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecU32TableHandle<'ctx> { type Row = VecU32; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecU32TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_u32"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_u32\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_u_32_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_u_32_type.rs index 021756cbbc2..0e507d872a0 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_u_32_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_u_32_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecU32 { pub n: Vec, } -impl __sdk::spacetime_module::InModule for VecU32 { +impl __sdk::InModule for VecU32 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_u_64_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_u_64_table.rs index f8f9dd26a84..94899797737 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_u_64_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_u_64_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_u_64_type::VecU64; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_u64`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_u_64().on_insert(...)`. pub struct VecU64TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecU64TableAccess for super::RemoteTables { } } -pub struct VecU64InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecU64DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecU64InsertCallbackId(__sdk::CallbackId); +pub struct VecU64DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecU64TableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecU64TableHandle<'ctx> { type Row = VecU64; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecU64TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_u64"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_u64\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_u_64_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_u_64_type.rs index d35ac106129..43e2dd6555d 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_u_64_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_u_64_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecU64 { pub n: Vec, } -impl __sdk::spacetime_module::InModule for VecU64 { +impl __sdk::InModule for VecU64 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_u_8_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_u_8_table.rs index 75b7c377c68..2b144242370 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_u_8_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_u_8_table.rs @@ -3,10 +3,9 @@ #![allow(unused)] use super::vec_u_8_type::VecU8; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_u8`. @@ -18,7 +17,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_u_8().on_insert(...)`. pub struct VecU8TableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -41,10 +40,10 @@ impl VecU8TableAccess for super::RemoteTables { } } -pub struct VecU8InsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecU8DeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecU8InsertCallbackId(__sdk::CallbackId); +pub struct VecU8DeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecU8TableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecU8TableHandle<'ctx> { type Row = VecU8; type EventContext = super::EventContext; @@ -82,10 +81,14 @@ impl<'ctx> __sdk::table::Table for VecU8TableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_u8"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_u8\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_u_8_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_u_8_type.rs index 84ab3879359..383edd29224 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_u_8_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_u_8_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -14,6 +13,6 @@ pub struct VecU8 { pub n: Vec, } -impl __sdk::spacetime_module::InModule for VecU8 { +impl __sdk::InModule for VecU8 { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_unit_struct_table.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_unit_struct_table.rs index 35c9fd01242..6707c2afd06 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_unit_struct_table.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_unit_struct_table.rs @@ -4,10 +4,9 @@ #![allow(unused)] use super::unit_struct_type::UnitStruct; use super::vec_unit_struct_type::VecUnitStruct; -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; /// Table handle for the table `vec_unit_struct`. @@ -19,7 +18,7 @@ use spacetimedb_sdk::{ /// but to directly chain method calls, /// like `ctx.db.vec_unit_struct().on_insert(...)`. pub struct VecUnitStructTableHandle<'ctx> { - imp: __sdk::db_connection::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -42,10 +41,10 @@ impl VecUnitStructTableAccess for super::RemoteTables { } } -pub struct VecUnitStructInsertCallbackId(__sdk::callbacks::CallbackId); -pub struct VecUnitStructDeleteCallbackId(__sdk::callbacks::CallbackId); +pub struct VecUnitStructInsertCallbackId(__sdk::CallbackId); +pub struct VecUnitStructDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::table::Table for VecUnitStructTableHandle<'ctx> { +impl<'ctx> __sdk::Table for VecUnitStructTableHandle<'ctx> { type Row = VecUnitStruct; type EventContext = super::EventContext; @@ -83,10 +82,14 @@ impl<'ctx> __sdk::table::Table for VecUnitStructTableHandle<'ctx> { } } +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("vec_unit_struct"); +} #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __anyhow::Result<__sdk::spacetime_module::TableUpdate> { - __sdk::spacetime_module::TableUpdate::parse_table_update_no_primary_key(raw_updates) +) -> __anyhow::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update_no_primary_key(raw_updates) .context("Failed to parse table update for table \"vec_unit_struct\"") } diff --git a/crates/sdk/tests/test-client/src/module_bindings/vec_unit_struct_type.rs b/crates/sdk/tests/test-client/src/module_bindings/vec_unit_struct_type.rs index d686ea5562c..955fcc294d0 100644 --- a/crates/sdk/tests/test-client/src/module_bindings/vec_unit_struct_type.rs +++ b/crates/sdk/tests/test-client/src/module_bindings/vec_unit_struct_type.rs @@ -2,10 +2,9 @@ // WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. #![allow(unused)] -use spacetimedb_sdk::{ - self as __sdk, +use spacetimedb_sdk::__codegen::{ + self as __sdk, __lib, __sats, __ws, anyhow::{self as __anyhow, Context as _}, - lib as __lib, sats as __sats, ws_messages as __ws, }; use super::unit_struct_type::UnitStruct; @@ -16,6 +15,6 @@ pub struct VecUnitStruct { pub s: Vec, } -impl __sdk::spacetime_module::InModule for VecUnitStruct { +impl __sdk::InModule for VecUnitStruct { type Module = super::RemoteModule; } diff --git a/crates/sdk/tests/test-client/src/pk_test_table.rs b/crates/sdk/tests/test-client/src/pk_test_table.rs index eab1cc425af..d113c5ed6be 100644 --- a/crates/sdk/tests/test-client/src/pk_test_table.rs +++ b/crates/sdk/tests/test-client/src/pk_test_table.rs @@ -1,8 +1,5 @@ use crate::module_bindings::*; -use spacetimedb_sdk::{ - sats::{i256, u256}, - Address, Event, Identity, Table, TableWithPrimaryKey, -}; +use spacetimedb_sdk::{i256, u256, Address, Event, Identity, Table, TableWithPrimaryKey}; use std::sync::Arc; use test_counter::TestCounter; @@ -164,13 +161,13 @@ macro_rules! impl_pk_test_table { } fn is_insert_reducer_event(event: &Reducer) -> bool { - matches!(event, Reducer::$insert_reducer_event(_)) + matches!(event, Reducer::$insert_reducer_event { .. }) } fn is_delete_reducer_event(event: &Reducer) -> bool { - matches!(event, Reducer::$delete_reducer_event(_)) + matches!(event, Reducer::$delete_reducer_event { .. }) } fn is_update_reducer_event(event: &Reducer) -> bool { - matches!(event, Reducer::$update_reducer_event(_)) + matches!(event, Reducer::$update_reducer_event { .. }) } fn insert(ctx: &impl RemoteDbContext, key: Self::PrimaryKey, value: i32) { diff --git a/crates/sdk/tests/test-client/src/simple_test_table.rs b/crates/sdk/tests/test-client/src/simple_test_table.rs index 766dbb27d4e..7fafa597327 100644 --- a/crates/sdk/tests/test-client/src/simple_test_table.rs +++ b/crates/sdk/tests/test-client/src/simple_test_table.rs @@ -1,8 +1,5 @@ use crate::module_bindings::*; -use spacetimedb_sdk::{ - sats::{i256, u256}, - Address, Event, Identity, Table, -}; +use spacetimedb_sdk::{i256, u256, Address, Event, Identity, Table}; use std::sync::{ atomic::{AtomicUsize, Ordering}, Arc, @@ -37,7 +34,7 @@ macro_rules! impl_simple_test_table { } fn is_insert_reducer_event(event: &Reducer) -> bool { - matches!(event, Reducer::$insert_reducer_event(_)) + matches!(event, Reducer::$insert_reducer_event { .. }) } fn insert(ctx: &impl RemoteDbContext, contents: Self::Contents) { diff --git a/crates/sdk/tests/test-client/src/unique_test_table.rs b/crates/sdk/tests/test-client/src/unique_test_table.rs index fd6b2cd3f58..1ca1bf65005 100644 --- a/crates/sdk/tests/test-client/src/unique_test_table.rs +++ b/crates/sdk/tests/test-client/src/unique_test_table.rs @@ -1,8 +1,5 @@ use crate::module_bindings::*; -use spacetimedb_sdk::{ - sats::{i256, u256}, - Address, Event, Identity, Table, -}; +use spacetimedb_sdk::{i256, u256, Address, Event, Identity, Table}; use std::sync::Arc; use test_counter::TestCounter; @@ -116,10 +113,10 @@ macro_rules! impl_unique_test_table { } fn is_insert_reducer_event(event: &Reducer) -> bool { - matches!(event, Reducer::$insert_reducer_event(_)) + matches!(event, Reducer::$insert_reducer_event { .. }) } fn is_delete_reducer_event(event: &Reducer) -> bool { - matches!(event, Reducer::$delete_reducer_event(_)) + matches!(event, Reducer::$delete_reducer_event { .. }) } fn insert(ctx: &impl RemoteDbContext, key: Self::Key, value: i32) { diff --git a/crates/standalone/src/control_db.rs b/crates/standalone/src/control_db.rs index 4a2bfa7363d..db44c730d7a 100644 --- a/crates/standalone/src/control_db.rs +++ b/crates/standalone/src/control_db.rs @@ -10,6 +10,11 @@ use spacetimedb_lib::bsatn; #[cfg(test)] mod tests; +/// A control database when SpacetimeDB is running standalone. +/// +/// Important note: The `Addresses` and `Identities` stored in this database +/// are stored as *LITTLE-ENDIAN* byte arrays. This means that printing such an array +/// in hexadecimal will result in the REVERSE of the standard way to print `Addresses` and `Identities`. #[derive(Clone)] pub struct ControlDb { db: sled::Db, @@ -140,7 +145,7 @@ impl ControlDb { let identity_bytes = database_identity.to_byte_array(); let tree = self.db.open_tree("dns")?; - tree.insert(domain.to_lowercase().as_bytes(), &identity_bytes)?; + tree.insert(domain.to_lowercase(), &identity_bytes)?; let tree = self.db.open_tree("reverse_dns")?; match tree.get(identity_bytes)? { @@ -220,8 +225,8 @@ impl ControlDb { pub fn get_database_by_identity(&self, identity: &Identity) -> Result> { let tree = self.db.open_tree("database_by_identity")?; - let key = identity.to_hex(); - let value = tree.get(key.as_bytes())?; + let key = identity.to_be_byte_array(); + let value = tree.get(&key[..])?; if let Some(value) = value { let database = compat::Database::from_slice(&value[..]).unwrap().into(); return Ok(Some(database)); @@ -233,7 +238,7 @@ impl ControlDb { let id = self.db.generate_id()?; let tree = self.db.open_tree("database_by_identity")?; - let key = database.database_identity.to_hex(); + let key = database.database_identity.to_be_byte_array(); if tree.contains_key(key)? { return Err(Error::DatabaseAlreadyExists(database.database_identity)); } @@ -256,9 +261,9 @@ impl ControlDb { if let Some(old_value) = tree.get(id.to_be_bytes())? { let database = compat::Database::from_slice(&old_value[..])?; - let key = database.database_identity().to_hex(); + let key = database.database_identity().to_be_byte_array(); - tree_by_identity.remove(key.as_bytes())?; + tree_by_identity.remove(&key[..])?; tree.remove(id.to_be_bytes())?; return Ok(Some(id)); } diff --git a/modules/rust-wasm-test/src/lib.rs b/modules/rust-wasm-test/src/lib.rs index cfc73fc7b23..e80b2aa8336 100644 --- a/modules/rust-wasm-test/src/lib.rs +++ b/modules/rust-wasm-test/src/lib.rs @@ -104,6 +104,11 @@ pub type TestAlias = TestA; #[spacetimedb::table(name = repeating_test_arg, scheduled(repeating_test))] pub struct RepeatingTestArg { + #[primary_key] + #[auto_inc] + scheduled_id: u64, + #[scheduled_at] + scheduled_at: spacetimedb::ScheduleAt, prev_time: Timestamp, } diff --git a/modules/sdk-test-cs/Lib.cs b/modules/sdk-test-cs/Lib.cs index 670e639024d..58ae3736cf8 100644 --- a/modules/sdk-test-cs/Lib.cs +++ b/modules/sdk-test-cs/Lib.cs @@ -1713,7 +1713,8 @@ public static void insert_large_table( EveryVecStruct v ) { - ctx.Db.large_table.Insert(new LargeTable { + ctx.Db.large_table.Insert(new LargeTable + { a = a, b = b, c = c, @@ -1742,7 +1743,8 @@ EveryVecStruct v [SpacetimeDB.Reducer] public static void insert_primitives_as_strings(ReducerContext ctx, EveryPrimitiveStruct s) { - ctx.Db.vec_string.Insert(new VecString { + ctx.Db.vec_string.Insert(new VecString + { s = typeof(EveryPrimitiveStruct) .GetFields() .Select(f => f.GetValue(s)!.ToString()!.ToLowerInvariant()) @@ -1765,4 +1767,33 @@ public static void insert_table_holds_table(ReducerContext ctx, OneU8 a, VecU8 b [SpacetimeDB.Reducer] public static void no_op_succeeds(ReducerContext ctx) { } + + [SpacetimeDB.Table(Name = "scheduled_table", Scheduled = nameof(send_scheduled_message))] + public partial struct ScheduledTable + { + public string text; + } + + [SpacetimeDB.Reducer] + public static void send_scheduled_message(ReducerContext ctx, ScheduledTable arg) + { + ulong id = arg.ScheduledId; + SpacetimeDB.ScheduleAt scheduleAt = arg.ScheduledAt; + string text = arg.text; + } + + [SpacetimeDB.Table(Name = "indexed_table")] + [SpacetimeDB.Index(Name = "player_id_index", BTree = [nameof(player_id)])] + public partial struct IndexedTable + { + uint player_id; + } + + [SpacetimeDB.Table(Name = "indexed_table_2")] + [SpacetimeDB.Index(Name = "player_id_snazz_index", BTree = [nameof(player_id), nameof(player_snazz)])] + public partial struct IndexedTable2 + { + uint player_id; + float player_snazz; + } } diff --git a/modules/sdk-test/src/lib.rs b/modules/sdk-test/src/lib.rs index c370b65dc3c..529b160f5fb 100644 --- a/modules/sdk-test/src/lib.rs +++ b/modules/sdk-test/src/lib.rs @@ -641,3 +641,31 @@ define_tables! { fn no_op_succeeds(_ctx: &ReducerContext) {} spacetimedb::filter!("SELECT * FROM one_u8"); + +#[spacetimedb::table(name = scheduled_table, scheduled(send_scheduled_message), public)] +pub struct ScheduledTable { + #[primary_key] + #[auto_inc] + scheduled_id: u64, + #[scheduled_at] + scheduled_at: spacetimedb::ScheduleAt, + text: String, +} + +#[spacetimedb::reducer] +fn send_scheduled_message(_ctx: &ReducerContext, arg: ScheduledTable) { + let _ = arg.text; + let _ = arg.scheduled_at; + let _ = arg.scheduled_id; +} + +#[spacetimedb::table(name = indexed_table, index(name=player_id_index, btree(columns = [player_id])))] +struct IndexedTable { + player_id: u32, +} + +#[spacetimedb::table(name = indexed_table_2, index(name=player_id_snazz_index, btree(columns = [player_id, player_snazz])))] +struct IndexedTable2 { + player_id: u32, + player_snazz: f32, +} diff --git a/smoketests/tests/modules.py b/smoketests/tests/modules.py index e9a7e5f3025..203a6e2a16c 100644 --- a/smoketests/tests/modules.py +++ b/smoketests/tests/modules.py @@ -144,6 +144,11 @@ class UploadModule2(Smoketest): #[spacetimedb::table(name = scheduled_message, public, scheduled(my_repeating_reducer))] pub struct ScheduledMessage { + #[primary_key] + #[auto_inc] + scheduled_id: u64, + #[scheduled_at] + scheduled_at: spacetimedb::ScheduleAt, prev: Timestamp, } diff --git a/smoketests/tests/namespaces.py b/smoketests/tests/namespaces.py index b1bd0eb268a..b6c18338830 100644 --- a/smoketests/tests/namespaces.py +++ b/smoketests/tests/namespaces.py @@ -23,7 +23,7 @@ def test_spacetimedb_ns_csharp(self): with tempfile.TemporaryDirectory() as tmpdir: self.spacetime("generate", "--out-dir", tmpdir, "--lang=cs", "--project-path", self.project_path) - self.assertEqual(count_matches(tmpdir, f"namespace {namespace}"), 4) + self.assertEqual(count_matches(tmpdir, f"namespace {namespace}"), 2) def test_custom_ns_csharp(self): """Ensure that when a custom namespace is specified on the command line, it actually gets used in generation""" @@ -33,5 +33,5 @@ def test_custom_ns_csharp(self): with tempfile.TemporaryDirectory() as tmpdir: self.spacetime("generate", "--out-dir", tmpdir, "--lang=cs", "--namespace", namespace, "--project-path", self.project_path) - self.assertEqual(count_matches(tmpdir, f"namespace {namespace}"), 4) - self.assertEqual(count_matches(tmpdir, "using SpacetimeDB;"), 4) + self.assertEqual(count_matches(tmpdir, f"namespace {namespace}"), 2) + self.assertEqual(count_matches(tmpdir, "using SpacetimeDB;"), 2) diff --git a/smoketests/tests/schedule_reducer.py b/smoketests/tests/schedule_reducer.py index 0b80d0f5c4e..01f6e57efdf 100644 --- a/smoketests/tests/schedule_reducer.py +++ b/smoketests/tests/schedule_reducer.py @@ -25,6 +25,11 @@ class CancelReducer(Smoketest): #[spacetimedb::table(name = scheduled_reducer_args, public, scheduled(reducer))] pub struct ScheduledReducerArgs { + #[primary_key] + #[auto_inc] + scheduled_id: u64, + #[scheduled_at] + scheduled_at: spacetimedb::ScheduleAt, num: i32, } @@ -53,6 +58,11 @@ class SubscribeScheduledTable(Smoketest): #[spacetimedb::table(name = scheduled_table, public, scheduled(my_reducer))] pub struct ScheduledTable { + #[primary_key] + #[auto_inc] + scheduled_id: u64, + #[scheduled_at] + scheduled_at: spacetimedb::ScheduleAt, prev: Timestamp, }