You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we try to use a type that isn’t a primitive rust type and it’s not a stdb table/tuple, the project won’t compile. Here is an example of using a uuid, which is defined in the uuid crate:
The reason this doesn’t compile, is that the macro generated functions for the table will want to be able to grab the schema for this type (because it knows its not a rust primitive)
error[E0425]: cannot find function `__struct_to_tuple__uuid` in this scope
--> crates/bitcraft-mini/src/lib.rs:15:1
|
15 | #[spacetimedb(table(1))]
| ^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
= note: this error originates in the attribute macro `spacetimedb` (in Nightly builds, run with -Z macro-backtrace for more info)
Best solution I could think of: treat this type as a json object. The TupleDef type for this field will just be string, and when we serialize/deserialize this type we just do it using json. As long as the type supports serde serialization we should be okay.
Alternate solution: We need a way for someone to add support for this type, likely by allowing them to specify a struct ⇒ TupleDef and TupleDef ⇒ struct func (plus any other required functions for that type).
Note: Because implement TupleTypeand similar hits error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate, then is useful to list with foreign types we could implement (like chrono, uuid, ...)
The text was updated successfully, but these errors were encountered:
If we try to use a type that isn’t a primitive rust type and it’s not a stdb table/tuple, the project won’t compile. Here is an example of using a
uuid
, which is defined in the uuid crate:The reason this doesn’t compile, is that the macro generated functions for the table will want to be able to grab the schema for this type (because it knows its not a rust primitive)
Best solution I could think of: treat this type as a json object. The TupleDef type for this field will just be string, and when we serialize/deserialize this type we just do it using json. As long as the type supports serde serialization we should be okay.
Alternate solution: We need a way for someone to add support for this type, likely by allowing them to specify a struct ⇒ TupleDef and TupleDef ⇒ struct func (plus any other required functions for that type).
Note: Because implement
TupleType
and similar hitserror[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
, then is useful to list with foreign types we could implement (likechrono, uuid, ...
)The text was updated successfully, but these errors were encountered: