Skip to content

Commit 4e7da2c

Browse files
Centrilcloutiertyler
authored andcommitted
Refactor bindings a bit + document it (#8)
* grandfathered docs improvements in bindings * improve bindings * address review comments * remove late bound lifetime * undo derive for Timestamp to bisect bug
1 parent 20c92b4 commit 4e7da2c

File tree

10 files changed

+345
-76
lines changed

10 files changed

+345
-76
lines changed

crates/bindings-macro/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ fn spacetimedb_tabletype_impl(item: syn::DeriveInput) -> syn::Result<TokenStream
670670
Some(quote! {
671671
// TODO: should we expose spacetimedb::query::FilterByIter ?
672672
#vis fn #filter_func_ident<'a>(#column_ident: &'a #column_type) -> impl Iterator<Item = Self> + 'a {
673-
spacetimedb::query::filter_by_field::<'a, Self, #column_type, #column_index>(#column_ident)
673+
spacetimedb::query::filter_by_field::<Self, #column_type, #column_index>(#column_ident)
674674
}
675675
})
676676
});

crates/bindings-sys/src/errno.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
/// Error code for "No such table".
12
pub const NOTAB: u16 = 1;
3+
4+
/// Error code for value/range not being found in a table.
25
pub const LOOKUP: u16 = 2;
6+
7+
/// Error code for when a unique constraint is violated.
38
pub const EXISTS: u16 = 3;
49

510
macro_rules! errnos {

crates/bindings-sys/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ pub fn create_index(index_name: &str, table_id: u32, index_type: u8, col_ids: &[
452452

453453
/// Finds all rows in the table identified by `table_id`,
454454
/// where the row has a column, identified by `col_id`,
455-
/// with data matching `val.
455+
/// with data matching `val`.
456456
///
457457
/// The rows found are bsatn encoded and then concatenated.
458458
/// The resulting byte string from the concatenation is written

crates/bindings/src/io.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
1+
//! Defines macros for basic IO corresponding to what the standard library provides.
2+
//! These macros include `println`, `print`, `eprintln`, `eprint`, and `dbg`.
3+
4+
/// Prints the provided arguments, terminated by a newline, as an `INFO` message to the console.
15
#[doc(hidden)]
26
#[macro_export]
37
macro_rules! println {
48
($($arg:tt)*) => ($crate::log::info!($($arg)*))
59
}
610

11+
/// Prints the provided arguments as an `INFO` message to the console.
712
#[doc(hidden)]
813
#[macro_export]
914
macro_rules! print {
1015
($($arg:tt)*) => ($crate::log::info!($($arg)*))
1116
}
1217

18+
/// Prints the provided arguments, terminated by a newline, as an `ERROR` message to the console.
1319
#[doc(hidden)]
1420
#[macro_export]
1521
macro_rules! eprintln {
1622
($($arg:tt)*) => ($crate::log::error!($($arg)*))
1723
}
1824

25+
/// Prints the provided arguments as an `ERROR` message to the console.
1926
#[doc(hidden)]
2027
#[macro_export]
2128
macro_rules! eprint {
2229
($($arg:tt)*) => ($crate::log::error!($($arg)*))
2330
}
2431

32+
/// Functions like the standard library's `dbg!` macro
33+
/// but prints as a `DEBUG` message to the console.
2534
#[macro_export]
2635
macro_rules! dbg {
2736
// NOTE: We cannot use `concat!` to make a static string as a format argument

0 commit comments

Comments
 (0)