Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SATS: add support needed for BFLATN => BSATN directly #750

Merged
merged 3 commits into from
Jan 24, 2024

Conversation

Centril
Copy link
Contributor

@Centril Centril commented Jan 24, 2024

Also some associated refactoring

Description of Changes

Extends spacetimedb_sats::ser::Serializer to support:

  • serializing from the BSATN encoded in granules and in blobs
  • serializing from a string encoded in granules

Adds spacetimedb_sats::bsatn::to_len which computes the length of a bsatn encoding without storing the encoding.

API and ABI breaking changes

None

Expected complexity level and risk

2, Some unsafe code, and this extends the Serializer trait.

@Centril Centril requested review from kazimuth and gefjon January 24, 2024 14:40
Copy link
Contributor

@gefjon gefjon left a comment

Choose a reason for hiding this comment

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

Comment-related suggestions. Code looks good.

Comment on lines 148 to 149
unsafe fn serialize_bsatn(self, _: &crate::AlgebraicType, bsatn: &[u8]) -> Result<Self::Ok, Self::Error> {
self.writer.put_slice(bsatn);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a meaningful debug_assert! you could add here that the bsatn is compatible with the (currently ignored) AlgebraicType?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, you could do basically what the safety requirement of calling this method is.
It is a bit expensive, possibly even for debug mode, but I'll add it for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the other cases, we'd need to make the iterator clonable but I can add that too.

@Centril Centril force-pushed the centril/sats-bflatn-bsatn branch from 402146b to cf2827c Compare January 24, 2024 16:00
Centril and others added 2 commits January 24, 2024 17:05
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
Signed-off-by: Mazdak Farrokhzad <twingoow@gmail.com>
@Centril Centril enabled auto-merge January 24, 2024 16:33
@Centril Centril added this pull request to the merge queue Jan 24, 2024
Merged via the queue into master with commit 80d9372 Jan 24, 2024
5 checks passed
@Centril Centril deleted the centril/sats-bflatn-bsatn branch January 24, 2024 17:35
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.

2 participants