Skip to content

Commit ff08875

Browse files
authored
feat: add search bindings (#159)
1 parent 5dc3936 commit ff08875

39 files changed

+2247
-3625
lines changed

Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ version = "1.8.3"
1515
# Dojo dependencies
1616
dojo-world = { git = "https://github.com/dojoengine/dojo", rev = "0afeb1bc" }
1717
dojo-types = { git = "https://github.com/dojoengine/dojo", rev = "0afeb1bc" }
18-
torii-proto = { git = "https://github.com/dojoengine/torii", rev = "8378c63" }
19-
torii-client = { git = "https://github.com/dojoengine/torii", rev = "8378c63" }
20-
torii-grpc-client = { git = "https://github.com/dojoengine/torii", rev = "8378c63" }
18+
torii-proto = { git = "https://github.com/dojoengine/torii", rev = "ffd7139" }
19+
torii-client = { git = "https://github.com/dojoengine/torii", rev = "ffd7139" }
20+
torii-grpc-client = { git = "https://github.com/dojoengine/torii", rev = "ffd7139" }
2121

2222
# Starknet dependencies
2323
starknet = "0.17.0"

bindings/c/dojo.h

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,18 @@ struct TokenBalance;
2929
struct TokenContract;
3030
struct Contract;
3131
struct TokenTransfer;
32+
struct TableSearchResults;
3233
struct Provider;
3334
struct Account;
3435
struct Ty;
3536
struct Model;
3637
struct Member;
3738
struct AchievementTask;
3839
struct PlayerAchievementProgress;
40+
struct SearchMatch;
3941
struct EnumOption;
4042
struct TaskProgress;
43+
struct SearchMatchField;
4144

4245
typedef enum BlockTag {
4346
Latest,
@@ -1052,6 +1055,38 @@ typedef struct TokenTransfer {
10521055
struct COptionc_char event_id;
10531056
} TokenTransfer;
10541057

1058+
typedef struct CArrayTableSearchResults {
1059+
struct TableSearchResults *data;
1060+
uintptr_t data_len;
1061+
} CArrayTableSearchResults;
1062+
1063+
typedef struct SearchResponse {
1064+
uint32_t total;
1065+
struct CArrayTableSearchResults results;
1066+
} SearchResponse;
1067+
1068+
typedef enum ResultSearchResponse_Tag {
1069+
OkSearchResponse,
1070+
ErrSearchResponse,
1071+
} ResultSearchResponse_Tag;
1072+
1073+
typedef struct ResultSearchResponse {
1074+
ResultSearchResponse_Tag tag;
1075+
union {
1076+
struct {
1077+
struct SearchResponse ok;
1078+
};
1079+
struct {
1080+
struct Error err;
1081+
};
1082+
};
1083+
} ResultSearchResponse;
1084+
1085+
typedef struct SearchQuery {
1086+
const char *query;
1087+
uint32_t limit;
1088+
} SearchQuery;
1089+
10551090
typedef enum ResultCArrayFieldElement_Tag {
10561091
OkCArrayFieldElement,
10571092
ErrCArrayFieldElement,
@@ -1285,6 +1320,17 @@ typedef struct TokenContract {
12851320
struct COptionU256 total_supply;
12861321
} TokenContract;
12871322

1323+
typedef struct CArraySearchMatch {
1324+
struct SearchMatch *data;
1325+
uintptr_t data_len;
1326+
} CArraySearchMatch;
1327+
1328+
typedef struct TableSearchResults {
1329+
const char *table;
1330+
uint32_t count;
1331+
struct CArraySearchMatch matches;
1332+
} TableSearchResults;
1333+
12881334
typedef struct CArrayEnumOption {
12891335
struct EnumOption *data;
12901336
uintptr_t data_len;
@@ -1384,6 +1430,31 @@ typedef struct PlayerAchievementProgress {
13841430
double progress_percentage;
13851431
} PlayerAchievementProgress;
13861432

1433+
typedef struct CArraySearchMatchField {
1434+
struct SearchMatchField *data;
1435+
uintptr_t data_len;
1436+
} CArraySearchMatchField;
1437+
1438+
typedef enum COptionf64_Tag {
1439+
Somef64,
1440+
Nonef64,
1441+
} COptionf64_Tag;
1442+
1443+
typedef struct COptionf64 {
1444+
COptionf64_Tag tag;
1445+
union {
1446+
struct {
1447+
double some;
1448+
};
1449+
};
1450+
} COptionf64;
1451+
1452+
typedef struct SearchMatch {
1453+
const char *id;
1454+
struct CArraySearchMatchField fields;
1455+
struct COptionf64 score;
1456+
} SearchMatch;
1457+
13871458
typedef struct EnumOption {
13881459
const char *name;
13891460
struct Ty *ty;
@@ -1395,6 +1466,11 @@ typedef struct TaskProgress {
13951466
bool completed;
13961467
} TaskProgress;
13971468

1469+
typedef struct SearchMatchField {
1470+
const char *key;
1471+
const char *value;
1472+
} SearchMatchField;
1473+
13981474
#ifdef __cplusplus
13991475
extern "C" {
14001476
#endif // __cplusplus
@@ -2034,6 +2110,18 @@ struct Resultbool client_update_token_transfer_subscription(struct ToriiClient *
20342110
const struct U256 *token_ids,
20352111
uintptr_t token_ids_len);
20362112

2113+
/**
2114+
* Performs a full-text search across indexed entities using FTS5
2115+
*
2116+
* # Parameters
2117+
* * `client` - Pointer to ToriiClient instance
2118+
* * `query` - Search query containing the search text and limit
2119+
*
2120+
* # Returns
2121+
* Result containing SearchResponse with results grouped by table or error
2122+
*/
2123+
struct ResultSearchResponse client_search(struct ToriiClient *client, struct SearchQuery query);
2124+
20372125
/**
20382126
* Serializes a string into a byte array
20392127
*

0 commit comments

Comments
 (0)