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

Add bitcode support #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PrismaPhonic
Copy link

This commit adds support for bitcode Encode and Decode. It does so gated behind a feature flag. The bitcode version is set to 0, with default features turned off, only derive feature added, and optional set to true. This allows libraries to specify the verison of bitcode they would prefer, and avoids using any other functionality of bitcode.

This commit adds support for bitcode Encode and Decode. It does so gated
behind a feature flag. The bitcode version is set to 0, with default
features turned off, only derive feature added, and optional set to
true. This allows libraries to specify the verison of bitcode they would
prefer, and avoids using any other functionality of bitcode.
@@ -23,6 +23,7 @@ rand = { version = "0.8", optional = true }
uuid = { version = "1.1", optional = true }
postgres-types = { version = "0.2.6", optional = true }
bytes = { version = "1.4.0", optional = true }
bitcode = { version = "0", features = ["derive"], default-features = false, optional = true }
Copy link
Owner

Choose a reason for hiding this comment

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

This should specify the minor version for major=0 versions.

Copy link

Choose a reason for hiding this comment

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

Specifying version = "0" allows the user to pick the major version of bitcode. Since ulid has reached version 1, it can't make breaking changes to update bitcode. For example if ulid added support for bitcode = "0.6" and bitcode = "0.7" was released, ulid couldn't update to it because that would be a breaking change.

bitcode = "0" allows any version the user wants to pick such as 0.5, 0.6 and future 0.7. The only tricky part is making sure ulid doesn't use APIs that will break between major versions. Luckily, bitcode docs specify that #[derive(bitcode::Encode, bitcode::Decode)] and feature = "derive" won't ever change between major versions.

While this method is unconventional, it allows 3rd party crates to support bitcode while allowing bitcode to remain unstable. One of bitcode's core goals is to keep improving its binary format. Unfortunately format changes are breaking changes so bitcode can't ever reach 1.0.

@@ -31,6 +32,7 @@ web-time = "1"
[dev-dependencies]
bencher = "0.1"
serde_derive = "1.0"
bitcode = "0.5"
Copy link
Owner

Choose a reason for hiding this comment

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

This is extra, remove.

Copy link

Choose a reason for hiding this comment

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

@PrismaPhonic hi, thank you for your amazing pr! Would you be able to update this pull request (PR) when you have time?

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