Skip to content

Conversation

@Centril
Copy link
Contributor

@Centril Centril commented Oct 10, 2023

Description of Changes

All cases of e.g., col_id/table_id/index_id/sequence_id: u32 are done away with and the newtypes are used instead for clearer code and more type safety. Moreover, the change in using ColId means we have to do .clone() and .map(..) less as we can stay in ColId-land until we actually have to transform from/into AlgebraicValue. I hope to eventually do away with all cases of reallocation due to the u32/ColId type difference as the representations are the same so a "transmute" should be possible.

The St*Fields enums now also use a macro for their definition to reduce boilerplate and to keep the entire definition in one place (strings, indices, and variant names).

API and ABI

  • This is a breaking change to the module ABI
  • This is a breaking change to the module API
  • This is a breaking change to the ClientAPI
  • This is a breaking change to the SDK API

If the API is breaking, please state below what will break

The module API breaks because the newtypes is used in the bindings* crates now.

Expected complexity level and risk

I'd rate this PR a 2.5; each change is rather trivial in itself, but there are a lot of them so there's some risk in numbers.
Moreover, there are some nixed reallocations and new allocations.

Copy link
Contributor

@kulakowski kulakowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know there's some outstanding big chunks of work at least @mamcx needs to get in, I trust you to coordinate about patch ordering.

unknown => { spacetimedb_sdk::log::error!("Event on an unknown reducer: {:?}", unknown); None }
}
match &function_call.reducer[..] {
"delete_pk_address" => _reducer_callbacks.handle_event_of_type::<delete_pk_address_reducer::DeletePkAddressArgs, ReducerEvent>(event, _state, ReducerEvent::DeletePkAddress),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get why this changed? Not a big deal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent question I also want the answer to xD

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a change in fmt.

built_in_into!(f64, F64);
built_in_into!(&str, String);
built_in_into!(&[u8], Bytes);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and some places it looks like ConstraintId isn't handled? I'm assuming ConstraitId is a type that we expect to use a lot more of shortly? And so it's named but not always plumbed all the way through etc

If that take is correct, I'm indifferent between you adding the impl for it here now, or later when it's need.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I have that in my PRs but here this move to another crate so I miss it.

ST_SEQUENCES_NAME,
(&StSequenceRow {
sequence_id: 1,
sequence_id: SequenceId(1),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly my curiosity, I don't demand this sort of consistency: How come sometimes you write 1.into() and sometimes SequenceId(1)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't in my original PR so @mamcx is best placed to answer that after the rebase. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do it pure by convenience, but should we enforce one way or another?


[dependencies]
getrandom = {workspace = true, optional = true}
spacetimedb-primitives = { path = "../primitives" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again for my edification: Why does this one not need to name the 0.7.1 tag? Is it because bindings-sys isn't published or something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left it as was before. I also wonder if we require the tag.

@kulakowski
Copy link
Contributor

I know there's some outstanding big chunks of work at least @mamcx needs to get in, I trust you to coordinate about patch ordering.

Ah I see now that mario pushed to this :)

@mamcx mamcx merged commit cba518d into master Oct 19, 2023
@Centril Centril deleted the move-newtype-ids branch May 17, 2024 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants