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

feat: updates the emoji ID API to be more idiomatic #6287

Merged
merged 3 commits into from
Apr 22, 2024

Conversation

AaronFeickert
Copy link
Collaborator

@AaronFeickert AaronFeickert commented Apr 18, 2024

Description

Updates the emoji ID public API to be more idiomatic.

Motivation and Context

The emoji ID public API includes functionality to convert to and from types like String and PublicKey, but not idiomatically. This PR updates the API to use From and FromStr trait implementations where possible. It also makes some minor changes to checksum function signatures to avoid unnecessary vector cloning, and improves a test.

How Has This Been Tested?

Existing tests pass.

What process can a PR reviewer use to test or verify this change?

Check that the new API is, in fact, more idiomatic :)

While this doesn't affect consensus or existing databases, this public API change is technically breaking. For example, existing documentation needs to be updated.

@ghpbot-tari-project ghpbot-tari-project added P-acks_required Process - Requires more ACKs or utACKs P-reviews_required Process - Requires a review from a lead maintainer to be merged labels Apr 18, 2024
Copy link

github-actions bot commented Apr 18, 2024

Test Results (CI)

    3 files    120 suites   37m 39s ⏱️
1 277 tests 1 277 ✅ 0 💤 0 ❌
3 823 runs  3 823 ✅ 0 💤 0 ❌

Results for commit 6762f9e.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Apr 18, 2024

Test Results (Integration tests)

 2 files  + 2  11 suites  +11   56m 57s ⏱️ + 56m 57s
33 tests +33  32 ✅ +32  0 💤 ±0  1 ❌ +1 
35 runs  +35  32 ✅ +32  0 💤 ±0  3 ❌ +3 

For more details on these failures, see this check.

Results for commit 6762f9e. ± Comparison against base commit 8f1eac6.

♻️ This comment has been updated with latest results.

Copy link
Member

@sdbondi sdbondi left a comment

Choose a reason for hiding this comment

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

Generally when something is constructed from a string the FromStr trait is more idiomatic.

fn do_something(emoji_id: EmojiId) { ... }

do_something(emoji_str.parse()?);
// equivalent to 
do_something(EmojiId::from_str(emoji_str)?);

It may make sense to implement From<PublicKey> for EmojiId if it isn't already

SWvheerden
SWvheerden previously approved these changes Apr 19, 2024
@ghpbot-tari-project ghpbot-tari-project removed the P-reviews_required Process - Requires a review from a lead maintainer to be merged label Apr 19, 2024
@SWvheerden
Copy link
Collaborator

SWvheerden commented Apr 19, 2024

FromStr is perhaps the better option here and not try_from

https://doc.rust-lang.org/std/str/trait.FromStr.html

@ghpbot-tari-project ghpbot-tari-project added the P-reviews_required Process - Requires a review from a lead maintainer to be merged label Apr 19, 2024
sdbondi
sdbondi previously approved these changes Apr 19, 2024
@ghpbot-tari-project ghpbot-tari-project removed the P-reviews_required Process - Requires a review from a lead maintainer to be merged label Apr 19, 2024
@ghpbot-tari-project ghpbot-tari-project added the P-reviews_required Process - Requires a review from a lead maintainer to be merged label Apr 19, 2024
@ghpbot-tari-project ghpbot-tari-project removed the P-reviews_required Process - Requires a review from a lead maintainer to be merged label Apr 22, 2024
@SWvheerden SWvheerden merged commit f538714 into tari-project:development Apr 22, 2024
15 of 17 checks passed
@AaronFeickert AaronFeickert deleted the emoji-id-api branch April 22, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-acks_required Process - Requires more ACKs or utACKs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants