rorm-lib 0.4.0

The FFI bindings to C.
Documentation
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

/**
* Placeholder struct representing the [rorm_db::Database] struct.
*/
typedef struct Database_ Database;

/**
* Placeholder struct representing the stream result from a query.
*/
typedef struct Stream_ Stream;

/**
* Placeholder struct representing the row gathered from a stream.
*/
typedef struct Row_ Row;

/**
* Placeholder struct representing a transaction
*/
typedef struct Transaction_ Transaction;


/**
 * Representation of the database backend.
 *
 *This is used to determine the correct driver and the correct dialect to use.
 */
enum DBBackend {
  /**
   * This exists to forbid default initializations with 0 on C side.
   * Using this type will result in an [crate::errors::Error::ConfigurationError]
   */
  Invalid,
  /**
   * SQLite backend
   */
  SQLite,
  /**
   * MySQL / MariaDB backend
   */
  MySQL,
  /**
   * Postgres backend
   */
  Postgres,
};
typedef int32_t DBBackend;

/**
 * Representation of a join type.
 */
typedef enum FFIJoinType {
  /**
   * Normal join operation.
   *
   * Equivalent to INNER JOIN
   */
  Join,
  /**
   * Cartesian product of the tables
   */
  CrossJoin,
  /**
   * Given:
   * T1 LEFT JOIN T2 ON ..
   *
   * First, an inner join is performed.
   * Then, for each row in T1 that does not satisfy the join condition with any row in T2,
   * a joined row is added with null values in columns of T2.
   */
  LeftJoin,
  /**
   * Given:
   * T1 RIGHT JOIN T2 ON ..
   *
   * First, an inner join is performed.
   * Then, for each row in T2 that does not satisfy the join condition with any row in T1,
   * a joined row is added with null values in columns of T1.
   */
  RightJoin,
  /**
   * Given:
   * T1 FULL JOIN T2 ON ..
   *
   * First, an inner join is performed.
   * Then, for each row in T2 that does not satisfy the join condition with any row in T1,
   * a joined row is added with null values in columns of T1.
   * Also, for each row in T1 that does not satisfy the join condition with any row in T2,
   * a joined row is added with null values in columns of T2.
   */
  FullJoin,
} FFIJoinType;

/**
 * Representation of the [Ordering]
 */
typedef enum FFIOrdering {
  /**
   * Ascending
   */
  Asc,
  /**
   * Descending
   */
  Desc,
} FFIOrdering;

/**
 * Representation of a string.
 */
typedef struct FFIString {
  const uint8_t *content;
  size_t size;
} FFIString;

/**
 * Configuration operation to connect to a database.
 *
 *Will be converted into [rorm_db::DatabaseConfiguration].
 *
 *`min_connections` and `max_connections` must not be 0.
 */
typedef struct DBConnectOptions {
  DBBackend backend;
  struct FFIString name;
  struct FFIString host;
  uint16_t port;
  struct FFIString user;
  struct FFIString password;
  uint32_t min_connections;
  uint32_t max_connections;
} DBConnectOptions;

/**
 * Representation of all error codes.
 */
typedef enum Error_Tag {
  /**
   * Everything's fine, nothing to worry about.
   */
  NoError,
  /**
   * Runtime was destroyed or never created and can therefore not be accessed.
   */
  MissingRuntimeError,
  /**
   * An error occurred while getting or accessing the runtime.
   */
  RuntimeError,
  /**
   * An error occurred while trying to convert a FFIString into a &str due to invalid content
   */
  InvalidStringError,
  /**
   * Configuration error
   */
  ConfigurationError,
  /**
   * Database error
   */
  DatabaseError,
  /**
   * There are no rows left in the stream
   */
  NoRowsLeftInStream,
  /**
   * Column could not be converted in the given type
   */
  ColumnDecodeError,
  /**
   * Column was not found in row
   */
  ColumnNotFoundError,
  /**
   * The index in the row was out of bounds
   */
  ColumnIndexOutOfBoundsError,
  /**
   * The provided date could not be parsed
   */
  InvalidDateError,
  /**
   * The provided time could not be parsed
   */
  InvalidTimeError,
  /**
   * The provided datetime could not be parsed
   */
  InvalidDateTimeError,
} Error_Tag;

typedef struct Error {
  Error_Tag tag;
  union {
    struct {
      struct FFIString runtime_error;
    };
    struct {
      struct FFIString configuration_error;
    };
    struct {
      struct FFIString database_error;
    };
  };
} Error;

/**
 * Representation of an FFI safe slice.
 */
typedef struct FFISlice_FFICondition {
  const struct FFICondition *content;
  size_t size;
} FFISlice_FFICondition;

/**
 * This enum represents all available unary conditions.
 */
typedef enum FFIUnaryCondition_Tag {
  /**
   * Representation of SQL's "{} IS NULL"
   */
  IsNull,
  /**
   * Representation of SQL's "{} IS NOT NULL"
   */
  IsNotNull,
  /**
   * Representation of SQL's "EXISTS {}"
   */
  Exists,
  /**
   * Representation of SQL's "NOT EXISTS {}"
   */
  NotExists,
  /**
   * Representation of SQL's "NOT {}"
   */
  Not,
} FFIUnaryCondition_Tag;

typedef struct FFIUnaryCondition {
  FFIUnaryCondition_Tag tag;
  union {
    struct {
      const struct FFICondition *is_null;
    };
    struct {
      const struct FFICondition *is_not_null;
    };
    struct {
      const struct FFICondition *exists;
    };
    struct {
      const struct FFICondition *not_exists;
    };
    struct {
      const struct FFICondition *not;
    };
  };
} FFIUnaryCondition;

/**
 * This enum represents a binary expression.
 */
typedef enum FFIBinaryCondition_Tag {
  /**
   * Representation of "{} = {}" in SQL
   */
  Equals,
  /**
   * Representation of "{} <> {}" in SQL
   */
  NotEquals,
  /**
   * Representation of "{} > {}" in SQL
   */
  Greater,
  /**
   * Representation of "{} >= {}" in SQL
   */
  GreaterOrEquals,
  /**
   * Representation of "{} < {}" in SQL
   */
  Less,
  /**
   * Representation of "{} <= {}" in SQL
   */
  LessOrEquals,
  /**
   * Representation of "{} LIKE {}" in SQL
   */
  Like,
  /**
   * Representation of "{} NOT LIKE {}" in SQL
   */
  NotLike,
  /**
   * Representation of "{} REGEXP {}" in SQL
   */
  Regexp,
  /**
   * Representation of "{} NOT REGEXP {}" in SQL
   */
  NotRegexp,
  /**
   * Representation of "{} IN {}" in SQL
   */
  In,
  /**
   * Representation of "{} NOT IN {}" in SQL
   */
  NotIn,
} FFIBinaryCondition_Tag;

typedef struct FFIBinaryCondition {
  FFIBinaryCondition_Tag tag;
  union {
    struct {
      const struct FFICondition *equals[2];
    };
    struct {
      const struct FFICondition *not_equals[2];
    };
    struct {
      const struct FFICondition *greater[2];
    };
    struct {
      const struct FFICondition *greater_or_equals[2];
    };
    struct {
      const struct FFICondition *less[2];
    };
    struct {
      const struct FFICondition *less_or_equals[2];
    };
    struct {
      const struct FFICondition *like[2];
    };
    struct {
      const struct FFICondition *not_like[2];
    };
    struct {
      const struct FFICondition *regexp[2];
    };
    struct {
      const struct FFICondition *not_regexp[2];
    };
    struct {
      const struct FFICondition *in[2];
    };
    struct {
      const struct FFICondition *not_in[2];
    };
  };
} FFIBinaryCondition;

/**
 * This enum represents all available ternary expression.
 */
typedef enum FFITernaryCondition_Tag {
  /**
   * Between represents "{} BETWEEN {} AND {}" from SQL
   */
  Between,
  /**
   * Between represents "{} NOT BETWEEN {} AND {}" from SQL
   */
  NotBetween,
} FFITernaryCondition_Tag;

typedef struct FFITernaryCondition {
  FFITernaryCondition_Tag tag;
  union {
    struct {
      const struct FFICondition *between[3];
    };
    struct {
      const struct FFICondition *not_between[3];
    };
  };
} FFITernaryCondition;

/**
 * Helper type to wrap [Option] ffi safe.
 */
typedef enum FFIOption_FFIString_Tag {
  /**
   * None value
   */
  None_FFIString,
  /**
   * Some value
   */
  Some_FFIString,
} FFIOption_FFIString_Tag;

typedef struct FFIOption_FFIString {
  FFIOption_FFIString_Tag tag;
  union {
    struct {
      struct FFIString some;
    };
  };
} FFIOption_FFIString;

/**
 * Representation of an FFI safe slice.
 */
typedef struct FFISlice_u8 {
  const uint8_t *content;
  size_t size;
} FFISlice_u8;

/**
 * Representation of a [chrono::NaiveTime].
 */
typedef struct FFITime {
  uint32_t hour;
  uint32_t min;
  uint32_t sec;
} FFITime;

/**
 * Representation of a [chrono::NaiveDate]
 */
typedef struct FFIDate {
  int32_t year;
  uint32_t month;
  uint32_t day;
} FFIDate;

/**
 * Representation of a [chrono::DateTime].
 */
typedef struct FFIDateTime {
  int32_t year;
  uint32_t month;
  uint32_t day;
  uint32_t hour;
  uint32_t min;
  uint32_t sec;
} FFIDateTime;

/**
 * This enum represents a value
 */
typedef enum FFIValue_Tag {
  /**
   * null representation
   */
  Null,
  /**
   * Representation of an identifier.
   * This variant will not be escaped, so do not
   * pass unchecked data to it.
   */
  Ident,
  /**
   * Representation of a column.
   */
  Column,
  /**
   * String representation
   */
  String,
  /**
   * i64 representation
   */
  I64,
  /**
   * i32 representation
   */
  I32,
  /**
   * i16 representation
   */
  I16,
  /**
   * Bool representation
   */
  Bool,
  /**
   * f64 representation
   */
  F64,
  /**
   * f32 representation
   */
  F32,
  /**
   * Binary representation
   */
  Binary,
  /**
   * Representation of time without timezones
   */
  NaiveTime,
  /**
   * Representation of dates without timezones
   */
  NaiveDate,
  /**
   * Representation of datetimes without timezones
   */
  NaiveDateTime,
} FFIValue_Tag;

typedef struct Column_Body {
  /**
   * Optional table name
   */
  struct FFIOption_FFIString table_name;
  /**
   * Name of the column
   */
  struct FFIString column_name;
} Column_Body;

typedef struct FFIValue {
  FFIValue_Tag tag;
  union {
    struct {
      struct FFIString ident;
    };
    Column_Body column;
    struct {
      struct FFIString string;
    };
    struct {
      int64_t i64;
    };
    struct {
      int32_t i32;
    };
    struct {
      int16_t i16;
    };
    struct {
      bool bool_;
    };
    struct {
      double f64;
    };
    struct {
      float f32;
    };
    struct {
      struct FFISlice_u8 binary;
    };
    struct {
      struct FFITime naive_time;
    };
    struct {
      struct FFIDate naive_date;
    };
    struct {
      struct FFIDateTime naive_date_time;
    };
  };
} FFIValue;

/**
 * This enum represents a condition tree.
 */
typedef enum FFICondition_Tag {
  /**
   * A list of [Condition]s, that get expanded to "{} AND {} ..."
   */
  Conjunction,
  /**
   * A list of [Condition]s, that get expanded to "{} OR {} ..."
   */
  Disjunction,
  /**
   * Representation of a unary condition.
   */
  UnaryCondition,
  /**
   * Representation of a binary condition.
   */
  BinaryCondition,
  /**
   * Representation of a ternary condition.
   */
  TernaryCondition,
  /**
   * Representation of a value.
   */
  Value,
} FFICondition_Tag;

typedef struct FFICondition {
  FFICondition_Tag tag;
  union {
    struct {
      struct FFISlice_FFICondition conjunction;
    };
    struct {
      struct FFISlice_FFICondition disjunction;
    };
    struct {
      struct FFIUnaryCondition unary_condition;
    };
    struct {
      struct FFIBinaryCondition binary_condition;
    };
    struct {
      struct FFITernaryCondition ternary_condition;
    };
    struct {
      struct FFIValue value;
    };
  };
} FFICondition;

/**
 * Representation of an FFI safe slice.
 */
typedef struct FFISlice_FFIString {
  const struct FFIString *content;
  size_t size;
} FFISlice_FFIString;

/**
 * Representation of an FFI safe slice.
 */
typedef struct FFISlice_FFIValue {
  const struct FFIValue *content;
  size_t size;
} FFISlice_FFIValue;

/**
 * Representation of an FFI safe slice.
 */
typedef struct FFISlice_FFISlice_FFIValue {
  const struct FFISlice_FFIValue *content;
  size_t size;
} FFISlice_FFISlice_FFIValue;

/**
 * FFI representation of a [SelectColumnImpl]
 */
typedef struct FFIColumnSelector {
  struct FFIOption_FFIString table_name;
  struct FFIString column_name;
  struct FFIOption_FFIString select_alias;
} FFIColumnSelector;

/**
 * Representation of an FFI safe slice.
 */
typedef struct FFISlice_FFIColumnSelector {
  const struct FFIColumnSelector *content;
  size_t size;
} FFISlice_FFIColumnSelector;

/**
 * FFI representation of a Join expression.
 */
typedef struct FFIJoin {
  /**
   * Type of the join operation
   */
  enum FFIJoinType join_type;
  /**
   * Name of the join table
   */
  struct FFIString table_name;
  /**
   * Alias for the join table
   */
  struct FFIString join_alias;
  /**
   * Condition to apply the join on
   */
  const struct FFICondition *join_condition;
} FFIJoin;

/**
 * Representation of an FFI safe slice.
 */
typedef struct FFISlice_FFIJoin {
  const struct FFIJoin *content;
  size_t size;
} FFISlice_FFIJoin;

/**
 * Representation of a [OrderByEntry]
 */
typedef struct FFIOrderByEntry {
  enum FFIOrdering ordering;
  struct FFIOption_FFIString table_name;
  struct FFIString column_name;
} FFIOrderByEntry;

/**
 * Representation of an FFI safe slice.
 */
typedef struct FFISlice_FFIOrderByEntry {
  const struct FFIOrderByEntry *content;
  size_t size;
} FFISlice_FFIOrderByEntry;

/**
 * Helper type to wrap [Option] ffi safe.
 */
typedef enum FFIOption_u64_Tag {
  /**
   * None value
   */
  None_u64,
  /**
   * Some value
   */
  Some_u64,
} FFIOption_u64_Tag;

typedef struct FFIOption_u64 {
  FFIOption_u64_Tag tag;
  union {
    struct {
      uint64_t some;
    };
  };
} FFIOption_u64;

/**
 * FFI representation of a Limit clause.
 */
typedef struct FFILimitClause {
  uint64_t limit;
  struct FFIOption_u64 offset;
} FFILimitClause;

/**
 * Helper type to wrap [Option] ffi safe.
 */
typedef enum FFIOption_FFILimitClause_Tag {
  /**
   * None value
   */
  None_FFILimitClause,
  /**
   * Some value
   */
  Some_FFILimitClause,
} FFIOption_FFILimitClause_Tag;

typedef struct FFIOption_FFILimitClause {
  FFIOption_FFILimitClause_Tag tag;
  union {
    struct {
      struct FFILimitClause some;
    };
  };
} FFIOption_FFILimitClause;

/**
 * Representation of an FFI safe slice.
 */
typedef struct FFISlice______Row {
  const Row *const *content;
  size_t size;
} FFISlice______Row;

/**
 * Representation of an FFI safe slice.
 */
typedef struct FFISlice_Row {
  const Row *content;
  size_t size;
} FFISlice_Row;

/**
 * Representation of an update.
 *
 *Consists of a column and the value to set to this column.
 */
typedef struct FFIUpdate {
  struct FFIString column;
  struct FFIValue value;
} FFIUpdate;

/**
 * Representation of an FFI safe slice.
 */
typedef struct FFISlice_FFIUpdate {
  const struct FFIUpdate *content;
  size_t size;
} FFISlice_FFIUpdate;

/**
 * Helper type to wrap [Option] ffi safe.
 */
typedef enum FFIOption_FFISlice_u8_Tag {
  /**
   * None value
   */
  None_FFISlice_u8,
  /**
   * Some value
   */
  Some_FFISlice_u8,
} FFIOption_FFISlice_u8_Tag;

typedef struct FFIOption_FFISlice_u8 {
  FFIOption_FFISlice_u8_Tag tag;
  union {
    struct {
      struct FFISlice_u8 some;
    };
  };
} FFIOption_FFISlice_u8;

/**
 * Helper type to wrap [Option] ffi safe.
 */
typedef enum FFIOption_bool_Tag {
  /**
   * None value
   */
  None_bool,
  /**
   * Some value
   */
  Some_bool,
} FFIOption_bool_Tag;

typedef struct FFIOption_bool {
  FFIOption_bool_Tag tag;
  union {
    struct {
      bool some;
    };
  };
} FFIOption_bool;

/**
 * Helper type to wrap [Option] ffi safe.
 */
typedef enum FFIOption_FFIDate_Tag {
  /**
   * None value
   */
  None_FFIDate,
  /**
   * Some value
   */
  Some_FFIDate,
} FFIOption_FFIDate_Tag;

typedef struct FFIOption_FFIDate {
  FFIOption_FFIDate_Tag tag;
  union {
    struct {
      struct FFIDate some;
    };
  };
} FFIOption_FFIDate;

/**
 * Helper type to wrap [Option] ffi safe.
 */
typedef enum FFIOption_FFIDateTime_Tag {
  /**
   * None value
   */
  None_FFIDateTime,
  /**
   * Some value
   */
  Some_FFIDateTime,
} FFIOption_FFIDateTime_Tag;

typedef struct FFIOption_FFIDateTime {
  FFIOption_FFIDateTime_Tag tag;
  union {
    struct {
      struct FFIDateTime some;
    };
  };
} FFIOption_FFIDateTime;

/**
 * Helper type to wrap [Option] ffi safe.
 */
typedef enum FFIOption_f32_Tag {
  /**
   * None value
   */
  None_f32,
  /**
   * Some value
   */
  Some_f32,
} FFIOption_f32_Tag;

typedef struct FFIOption_f32 {
  FFIOption_f32_Tag tag;
  union {
    struct {
      float some;
    };
  };
} FFIOption_f32;

/**
 * Helper type to wrap [Option] ffi safe.
 */
typedef enum FFIOption_f64_Tag {
  /**
   * None value
   */
  None_f64,
  /**
   * Some value
   */
  Some_f64,
} FFIOption_f64_Tag;

typedef struct FFIOption_f64 {
  FFIOption_f64_Tag tag;
  union {
    struct {
      double some;
    };
  };
} FFIOption_f64;

/**
 * Helper type to wrap [Option] ffi safe.
 */
typedef enum FFIOption_i16_Tag {
  /**
   * None value
   */
  None_i16,
  /**
   * Some value
   */
  Some_i16,
} FFIOption_i16_Tag;

typedef struct FFIOption_i16 {
  FFIOption_i16_Tag tag;
  union {
    struct {
      int16_t some;
    };
  };
} FFIOption_i16;

/**
 * Helper type to wrap [Option] ffi safe.
 */
typedef enum FFIOption_i32_Tag {
  /**
   * None value
   */
  None_i32,
  /**
   * Some value
   */
  Some_i32,
} FFIOption_i32_Tag;

typedef struct FFIOption_i32 {
  FFIOption_i32_Tag tag;
  union {
    struct {
      int32_t some;
    };
  };
} FFIOption_i32;

/**
 * Helper type to wrap [Option] ffi safe.
 */
typedef enum FFIOption_i64_Tag {
  /**
   * None value
   */
  None_i64,
  /**
   * Some value
   */
  Some_i64,
} FFIOption_i64_Tag;

typedef struct FFIOption_i64 {
  FFIOption_i64_Tag tag;
  union {
    struct {
      int64_t some;
    };
  };
} FFIOption_i64;

/**
 * Helper type to wrap [Option] ffi safe.
 */
typedef enum FFIOption_FFITime_Tag {
  /**
   * None value
   */
  None_FFITime,
  /**
   * Some value
   */
  Some_FFITime,
} FFIOption_FFITime_Tag;

typedef struct FFIOption_FFITime {
  FFIOption_FFITime_Tag tag;
  union {
    struct {
      struct FFITime some;
    };
  };
} FFIOption_FFITime;

/**
 * Connect to the database using the provided [DBConnectOptions].
 *
 *You must provide a callback with the following parameters:
 *
 *The first parameter is the `context` pointer. The second parameter will be a pointer to the Database connection. It will be needed to make queries. The last parameter holds an [Error] enum.
 *
 ***Important**: Rust does not manage the memory of the database. To properly free it, use [rorm_db_free].
 *
 *This function is called from an asynchronous context.
 */
void rorm_db_connect(struct DBConnectOptions options,
                     void (*callback)(void*, Database*, struct Error),
                     void* context);

/**
 * This function deletes rows from the database based on the given conditions.
 *
 ***Parameter**: - `db`: Reference to the Database, provided by [rorm_db_connect]. - `transaction`: Mutable pointer to a Transaction. Can be a null pointer to ignore this parameter. - `model`: Name of the table to query. - `condition`: Pointer to a [Condition]. - `callback`: callback function. Takes the `context`, a pointer to a vec of rows and an [Error]. - `context`: Pass through void pointer.
 *
 *Returns the rows affected of the delete statement. Note that this also includes     relations, etc.
 *
 ***Important**: - Make sure that `db`, `model` and `condition` are allocated until the callback is executed.
 *
 *This function is called from an asynchronous context.
 */
void rorm_db_delete(const Database *db,
                    Transaction *transaction,
                    struct FFIString model,
                    const struct FFICondition *condition,
                    void (*callback)(void*, uint64_t, struct Error),
                    void* context);

/**
 * Free the connection to the database.
 *
 *Takes the pointer to the database instance.
 *
 ***Important**: Do not call this function more than once!
 *
 *This function is called completely synchronously.
 */
void rorm_db_free(Database*);

/**
 * This function inserts a row into the database.
 *
 ***Parameter**: - `db`: Reference to the Database, provided by [rorm_db_connect]. - `transaction`: Mutable pointer to a Transaction. Can be a null pointer to ignore this parameter. - `model`: Name of the table to query. - `columns`: Array of columns to insert to the table. - `row`: List of values to insert. Must be of the same length as `columns`. - `callback`: callback function. Takes the `context` and an [Error]. - `context`: Pass through void pointer.
 *
 ***Important**: - Make sure that `db`, `model`, `columns` and `row` are allocated until the callback is executed.
 *
 *This function is called from an asynchronous context.
 */
void rorm_db_insert(const Database *db,
                    Transaction *transaction,
                    struct FFIString model,
                    struct FFISlice_FFIString columns,
                    struct FFISlice_FFIValue row,
                    void (*callback)(void*, struct Error),
                    void* context);

/**
 * This function inserts multiple rows into the database.
 *
 ***Parameter**: - `db`: Reference to the Database, provided by [rorm_db_connect]. - `transaction`: Mutable pointer to a Transaction. Can be a null pointer to ignore this parameter. - `model`: Name of the table to query. - `columns`: Array of columns to insert to the table. - `rows`: List of list of values to insert. The inner lists must be of the same length as `columns`. - `callback`: callback function. Takes the `context` and an [Error]. - `context`: Pass through void pointer.
 *
 ***Important**: - Make sure that `db`, `model`, `columns` and `rows` are allocated until the callback is executed.
 *
 *This function is called from an asynchronous context.
 */
void rorm_db_insert_bulk(const Database *db,
                         Transaction *transaction,
                         struct FFIString model,
                         struct FFISlice_FFIString columns,
                         struct FFISlice_FFISlice_FFIValue rows,
                         void (*callback)(void*, struct Error),
                         void* context);

/**
 * This function queries the database given the provided parameter and returns all matched rows.
 *
 *To include the statement in a transaction specify `transaction` as a valid Transaction. As the Transaction needs to be mutable, it is important to not use the Transaction anywhere else until the callback is finished.
 *
 *If the statement should be executed **not** in a Transaction, specify a null pointer.
 *
 ***Parameter**: - `db`: Reference to the Database, provided by [rorm_db_connect] - `transaction`: Mutable pointer to a Transaction. Can be a null pointer to ignore this parameter. - `model`: Name of the table to query. - `columns`: Array of columns to retrieve from the database. - `joins`: Array of joins to add to the query. - `condition`: Pointer to a [Condition]. - `order_by`: Array of [FFIOrderByEntry]. - `limit`: Optional limit / offset to set to the query. - `callback`: callback function. Takes the `context`, a FFISlice of rows and an [Error]. - `context`: Pass through void pointer.
 *
 ***Important**: - Make sure that `db`, `model`, `columns`, `joins` and `condition` are allocated until the callback is executed. - The FFISlice returned in the callback is freed after the callback has ended.
 *
 *This function is called from an asynchronous context.
 */
void rorm_db_query_all(const Database *db,
                       Transaction *transaction,
                       struct FFIString model,
                       struct FFISlice_FFIColumnSelector columns,
                       struct FFISlice_FFIJoin joins,
                       const struct FFICondition *condition,
                       struct FFISlice_FFIOrderByEntry order_by,
                       struct FFIOption_FFILimitClause limit,
                       void (*callback)(void*, struct FFISlice______Row, struct Error),
                       void* context);

/**
 * This function queries the database given the provided parameter and returns one matched row.
 *
 *To include the statement in a transaction specify `transaction` as a valid Transaction. As the Transaction needs to be mutable, it is important to not use the Transaction anywhere else until the callback is finished.
 *
 *If the statement should be executed **not** in a Transaction, specify a null pointer.
 *
 ***Parameter**: - `db`: Reference to the Database, provided by [rorm_db_connect]. - `transaction`: Mutable pointer to a Transaction. Can be a null pointer to ignore this parameter. - `model`: Name of the table to query. - `columns`: Array of columns to retrieve from the database. - `joins`: Array of joins to add to the query. - `condition`: Pointer to a [Condition]. - `order_by`: Array of [FFIOrderByEntry]. - `offset`: Optional offset to set to the query. - `callback`: callback function. Takes the `context`, a pointer to a row and an [Error]. - `context`: Pass through void pointer.
 *
 ***Important**: - Make sure that `db`, `model`, `columns`, `joins` and `condition` are allocated until the callback is executed.
 *
 *This function is called from an asynchronous context.
 */
void rorm_db_query_one(const Database *db,
                       Transaction *transaction,
                       struct FFIString model,
                       struct FFISlice_FFIColumnSelector columns,
                       struct FFISlice_FFIJoin joins,
                       const struct FFICondition *condition,
                       struct FFISlice_FFIOrderByEntry order_by,
                       struct FFIOption_u64 offset,
                       void (*callback)(void*, Row*, struct Error),
                       void* context);

/**
 * This function queries the database given the provided parameter and returns one optional matched row. If no results could be retrieved, None is returned.
 *
 *To include the statement in a transaction specify `transaction` as a valid Transaction. As the Transaction needs to be mutable, it is important to not use the Transaction anywhere else until the callback is finished.
 *
 *If the statement should be executed **not** in a Transaction, specify a null pointer.
 *
 ***Parameter**: - `db`: Reference to the Database, provided by [rorm_db_connect]. - `transaction`: Mutable pointer to a Transaction. Can be a null pointer to ignore this parameter. - `model`: Name of the table to query. - `columns`: Array of columns to retrieve from the database. - `joins`: Array of joins to add to the query. - `condition`: Pointer to a [Condition]. - `order_by`: Array of [FFIOrderByEntry]. - `offset`: Optional offset to set to the query. - `callback`: callback function. Takes the `context`, a pointer to a row and an [Error]. - `context`: Pass through void pointer.
 *
 ***Important**: - Make sure that `db`, `model`, `columns`, `joins` and `condition` are allocated until the callback is executed.
 *
 *This function is called from an asynchronous context.
 */
void rorm_db_query_optional(const Database *db,
                            Transaction *transaction,
                            struct FFIString model,
                            struct FFISlice_FFIColumnSelector columns,
                            struct FFISlice_FFIJoin joins,
                            const struct FFICondition *condition,
                            struct FFISlice_FFIOrderByEntry order_by,
                            struct FFIOption_u64 offset,
                            void (*callback)(void*, Row*, struct Error),
                            void* context);

/**
 * This function queries the database given the provided parameter.
 *
 *Returns a pointer to the created stream.
 *
 ***Parameter**: - `db`: Reference to the Database, provided by [rorm_db_connect]. - `transaction`: Mutable pointer to a Transaction. Can be a null pointer to ignore this parameter. - `model`: Name of the table to query. - `columns`: Array of columns to retrieve from the database. - `joins`: Array of joins to add to the query. - `condition`: Pointer to a [Condition]. - `order_by`: Array of [FFIOrderByEntry]. - `limit`: Optional limit / offset to set to the query. - `callback`: callback function. Takes the `context`, a stream pointer and an [Error]. - `context`: Pass through void pointer.
 *
 *This function is called completely synchronously.
 */
void rorm_db_query_stream(const Database *db,
                          Transaction *transaction,
                          struct FFIString model,
                          struct FFISlice_FFIColumnSelector columns,
                          struct FFISlice_FFIJoin joins,
                          const struct FFICondition *condition,
                          struct FFISlice_FFIOrderByEntry order_by,
                          struct FFIOption_FFILimitClause limit,
                          void (*callback)(void*, Stream*, struct Error),
                          void* context);

/**
 * This function executes a raw SQL statement.
 *
 *Statements are executed as prepared statements, if possible.
 *
 *To define placeholders, use `?` in SQLite and MySQL and $1, $n in Postgres. The corresponding parameters are bound in order to the query.
 *
 *The number of placeholder must match with the number of provided bind parameters.
 *
 *To include the statement in a transaction specify `transaction` as a valid Transaction. As the Transaction needs to be mutable, it is important to not use the Transaction anywhere else until the callback is finished.
 *
 *If the statement should be executed **not** in a Transaction, specify a null pointer.
 *
 ***Parameter**: - `db`: Reference to the Database, provided by [rorm_db_connect]. - `transaction`: Mutable pointer to a Transaction. Can be a null pointer to ignore this parameter. - `query_string`: SQL statement to execute. - `bind_params`: Slice of FFIValues to bind to the query. - `callback`: callback function. Takes the `context`, a pointer to a slice of rows and an [Error]. - `context`: Pass through void pointer.
 *
 ***Important**: - Make sure `db`, `query_string` and `bind_params` are allocated until the callback was executed. - The FFISlice returned in the callback is freed after the callback has ended.
 *
 *This function is called from an asynchronous context.
 */
void rorm_db_raw_sql(const Database *db,
                     Transaction *transaction,
                     struct FFIString query_string,
                     struct FFISlice_FFIValue bind_params,
                     void (*callback)(void*, struct FFISlice_Row, struct Error),
                     void* context);

/**
 * Starts a transaction on the current database connection.
 *
 ***Parameter**: - `db`: Reference to the Database, provided by [rorm_db_connect]. - `callback`: callback function. Takes the `context`, a pointer to a transaction and an [Error]. - `context`: Pass through void pointer.
 *
 ***Important**: Rust does not manage the memory of the transaction. To properly free it, use [rorm_transaction_commit] or [rorm_transaction_abort].
 *
 *This function is called from an asynchronous context.
 */
void rorm_db_start_transaction(const Database *db,
                               void (*callback)(void*, Transaction*, struct Error),
                               void* context);

/**
 * This function updates rows in the database.
 *
 ***Parameter**: - `db`: Reference to the Database, provided by [rorm_db_connect]. - `transaction`: Mutable pointer to a Transaction. Can be a null pointer to ignore this parameter. - `model`: Name of the table to query. - `updates`: List of [FFIUpdate] to apply. - `condition`: Pointer to a [Condition]. - `callback`: callback function. Takes the `context`, the rows affected and an [Error]. - `context`: Pass through void pointer.
 *
 ***Important**: - Make sure that `db`, `model`, `updates` and `condition` are allocated until the callback is executed.
 *
 *This function is called from an asynchronous context.
 */
void rorm_db_update(const Database *db,
                    Transaction *transaction,
                    struct FFIString model,
                    struct FFISlice_FFIUpdate updates,
                    const struct FFICondition *condition,
                    void (*callback)(void*, uint64_t, struct Error),
                    void* context);

/**
 * Frees the row given as parameter.
 *
 *The function panics if the provided pointer is invalid.
 *
 ***Important**: Do not call this function on the same pointer more than once!
 *
 *This function is called completely synchronously.
 */
void rorm_row_free(Row*);

/**
 * Tries to retrieve an FFISlice of a u8 from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
struct FFISlice_u8 rorm_row_get_binary(const Row *row_ptr,
                                       struct FFIString index,
                                       struct Error *error_ptr);

/**
 * Tries to retrieve a bool from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
bool rorm_row_get_bool(const Row *row_ptr,
                       struct FFIString index,
                       struct Error *error_ptr);

/**
 * Tries to retrieve a FFIDate from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
struct FFIDate rorm_row_get_date(const Row *row_ptr,
                                 struct FFIString index,
                                 struct Error *error_ptr);

/**
 * Tries to retrieve a FFIDateTime from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
struct FFIDateTime rorm_row_get_datetime(const Row *row_ptr,
                                         struct FFIString index,
                                         struct Error *error_ptr);

/**
 * Tries to retrieve an f32 from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
float rorm_row_get_f32(const Row *row_ptr,
                       struct FFIString index,
                       struct Error *error_ptr);

/**
 * Tries to retrieve an f64 from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
double rorm_row_get_f64(const Row *row_ptr,
                        struct FFIString index,
                        struct Error *error_ptr);

/**
 * Tries to retrieve an i16 from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
int16_t rorm_row_get_i16(const Row *row_ptr,
                         struct FFIString index,
                         struct Error *error_ptr);

/**
 * Tries to retrieve an i32 from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
int32_t rorm_row_get_i32(const Row *row_ptr,
                         struct FFIString index,
                         struct Error *error_ptr);

/**
 * Tries to retrieve an i64 from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
int64_t rorm_row_get_i64(const Row *row_ptr,
                         struct FFIString index,
                         struct Error *error_ptr);

/**
 * Tries to retrieve a nullable FFISlice of a u8 from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
struct FFIOption_FFISlice_u8 rorm_row_get_null_binary(const Row *row_ptr,
                                                      struct FFIString index,
                                                      struct Error *error_ptr);

/**
 * Tries to retrieve a nullable bool from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
struct FFIOption_bool rorm_row_get_null_bool(const Row *row_ptr,
                                             struct FFIString index,
                                             struct Error *error_ptr);

/**
 * Tries to retrieve a nullable FFIDate from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
struct FFIOption_FFIDate rorm_row_get_null_date(const Row *row_ptr,
                                                struct FFIString index,
                                                struct Error *error_ptr);

/**
 * Tries to retrieve a nullable FFIDate from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
struct FFIOption_FFIDateTime rorm_row_get_null_datetime(const Row *row_ptr,
                                                        struct FFIString index,
                                                        struct Error *error_ptr);

/**
 * Tries to retrieve a nullable f32 from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
struct FFIOption_f32 rorm_row_get_null_f32(const Row *row_ptr,
                                           struct FFIString index,
                                           struct Error *error_ptr);

/**
 * Tries to retrieve a nullable f64 from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
struct FFIOption_f64 rorm_row_get_null_f64(const Row *row_ptr,
                                           struct FFIString index,
                                           struct Error *error_ptr);

/**
 * Tries to retrieve a nullable i16 from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
struct FFIOption_i16 rorm_row_get_null_i16(const Row *row_ptr,
                                           struct FFIString index,
                                           struct Error *error_ptr);

/**
 * Tries to retrieve a nullable i32 from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
struct FFIOption_i32 rorm_row_get_null_i32(const Row *row_ptr,
                                           struct FFIString index,
                                           struct Error *error_ptr);

/**
 * Tries to retrieve a nullable i64 from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
struct FFIOption_i64 rorm_row_get_null_i64(const Row *row_ptr,
                                           struct FFIString index,
                                           struct Error *error_ptr);

/**
 * Tries to retrieve a nullable FFIString from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
struct FFIOption_FFIString rorm_row_get_null_str(const Row *row_ptr,
                                                 struct FFIString index,
                                                 struct Error *error_ptr);

/**
 * Tries to retrieve a nullable FFITime from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
struct FFIOption_FFITime rorm_row_get_null_time(const Row *row_ptr,
                                                struct FFIString index,
                                                struct Error *error_ptr);

/**
 * Tries to retrieve an FFIString from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
struct FFIString rorm_row_get_str(const Row *row_ptr,
                                  struct FFIString index,
                                  struct Error *error_ptr);

/**
 * Tries to retrieve a FFITime from the given row pointer.
 *
 ***Parameter**: - `row_ptr`: Pointer to a row. - `index`: Name of the column to retrieve from the row. - `error_ptr`: Pointer to an [Error]. Gets only written to if an error occurs.
 *
 *This function is called completely synchronously.
 */
struct FFITime rorm_row_get_time(const Row *row_ptr,
                                 struct FFIString index,
                                 struct Error *error_ptr);

/**
 * Shutdown the runtime.
 *
 *Specify the amount of time to wait in milliseconds.
 *
 *If no runtime is currently existing, a [Error::MissingRuntimeError] will be returned. If the runtime could not be locked, a [Error::RuntimeError] containing further information will be returned.
 *
 *This function is called completely synchronously.
 */
void rorm_runtime_shutdown(uint64_t duration,
                           void (*callback)(void*, struct Error),
                           void* context);

/**
 * This function is used to initialize and start the async runtime.
 *
 *It is needed as rorm is completely written asynchronously.
 *
 ***Important**: Do not forget to stop the runtime using [rorm_runtime_shutdown]!
 *
 *This function is called completely synchronously.
 */
void rorm_runtime_start(void (*callback)(void*, struct Error), void* context);

/**
 * Frees the stream given as parameter.
 *
 *This function panics if the pointer to the stream is invalid.
 *
 ***Important**: Do not call this function more than once!
 *
 *This function is called completely synchronously.
 */
void rorm_stream_free(Stream*);

/**
 * Use this function to retrieve a pointer to a row on a stream.
 *
 ***Parameter**: - `stream_ptr`: Mutable pointer to the stream that is obtained from [rorm_db_query_stream]. - `callback`: callback function. Takes the `context`, a row pointer and a [Error]. - `context`: Pass through void pointer
 *
 ***Important**: - Do not call this function multiple times on the same stream, unless all given callbacks have returned successfully. Calling the function multiple times on the same stream will result in undefined behaviour! - Do not call this function on the same stream if the previous call returned a [Error::NoRowsLeftInStream]. - Do not use pass the stream to another function unless the callback of the current call is finished
 *
 *This function is called from an asynchronous context.
 */
void rorm_stream_get_row(Stream *stream_ptr,
                         void (*callback)(void*, Row*, struct Error),
                         void* context);

/**
 * Commits a transaction.
 *
 *All previous operations will be applied to the database.
 *
 ***Parameter**: - `transaction`: Pointer to a valid transaction, provided by [rorm_db_start_transaction]. - `callback`: callback function. Takes the `context` and an [Error]. - `context`: Pass through void pointer.
 *
 ***Important**: Rust takes ownership of `transaction` and frees it after using. Don't use it anywhere else after calling this function!
 *
 *This function is called from an asynchronous context.
 */
void rorm_transaction_commit(Transaction *transaction,
                             void (*callback)(void*, struct Error),
                             void* context);

/**
 * Rollback a transaction and abort it.
 *
 *All previous operations will be discarded.
 *
 ***Parameter**: - `transaction`: Pointer to a valid transaction, provided by [rorm_db_start_transaction]. - `callback`: callback function. Takes the `context` and an [Error]. - `context`: Pass through void pointer.
 *
 ***Important**: Rust takes ownership of `transaction` and frees it after using. Don't use it anywhere else after calling this function!
 *
 *This function is called from an asynchronous context.
 */
void rorm_transaction_rollback(Transaction *transaction,
                               void (*callback)(void*, struct Error),
                               void* context);