Skip to content

Commit

Permalink
add additional sample for primitve with generic
Browse files Browse the repository at this point in the history
  • Loading branch information
andogq committed Aug 12, 2024
1 parent d9df2cd commit 5d3ba50
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions examples/chaos/bindings/UniqueType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type UniqueType = { value: number, };
3 changes: 2 additions & 1 deletion examples/chaos/bindings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import type { Mutation } from "@qubit-rs/client";
import type { Subscription } from "@qubit-rs/client";
import type { NestedStruct } from "./NestedStruct.ts";
import type { MyEnum } from "./MyEnum.ts";
import type { UniqueType } from "./UniqueType.ts";
import type { Metadata } from "./Metadata.ts";
import type { User } from "./User.ts";
import type { Test } from "./Test.ts";

export type QubitServer = { version: Query<[], string>, count: Mutation<[], number>, countdown: Subscription<[min: number, max: number, ], number>, array: Query<[], Array<string>>, enum_test: Query<[], MyEnum>, user: { someHandler: Query<[_id: string, ], User>, create: Mutation<[name: string, email: string, age: number, ], User>, list: Query<[], Array<Test>>, asdf: Query<[], null> } };
export type QubitServer = { version: Query<[], string>, count: Mutation<[], number>, countdown: Subscription<[min: number, max: number, ], number>, array: Query<[], Array<string>>, enum_test: Query<[], MyEnum>, array_type: Query<[], Array<UniqueType>>, user: { someHandler: Query<[_id: string, ], User>, create: Mutation<[name: string, email: string, age: number, ], User>, list: Query<[], Array<Test>>, asdf: Query<[], null> } };
11 changes: 11 additions & 0 deletions examples/chaos/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ async fn array() -> Vec<String> {
vec!["a".to_string(), "b".to_string(), "c".to_string()]
}

#[derive(Clone, Serialize, TS)]
struct UniqueType {
value: usize,
}

#[handler(query)]
async fn array_type() -> Vec<UniqueType> {
vec![]
}

#[derive(Clone, Serialize, TS)]
struct NestedStruct {
a: f32,
Expand Down Expand Up @@ -194,6 +204,7 @@ async fn main() {
.handler(countdown)
.handler(array)
.handler(enum_test)
.handler(array_type)
.nest("user", user::create_router());

// Save the router's bindings
Expand Down

0 comments on commit 5d3ba50

Please sign in to comment.