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

Fix hash type and Vec<u8> tests #61

Merged
merged 3 commits into from
Jul 15, 2022
Merged

Conversation

LeoNero
Copy link
Member

@LeoNero LeoNero commented Jul 11, 2022

This PR is totally open for discussion, since I am not sure if those changes are actually necessary.

This builds upon #59. I will rebase the commits once #59 is merged.

Now, from_str for Vec allows strings starting with 0x.

bytes now uses the AsRef implementation. This potentially increases the number of types that can use the default implementation, but also makes things a bit clear.

@TheCharlatan
Copy link
Member

Needs conflict resolve.

src/util.rs Outdated Show resolved Hide resolved
@LeoNero
Copy link
Member Author

LeoNero commented Jul 13, 2022

@TheCharlatan @h4sh3d so I spent a looot of time playing around and reading the code from hex crate and fixed_hash crate. I think having FromHex would be a good trait bound too, so from_str could be replaced by from_hex, but neither PaymentId nor Hash implement it, so I decided to not mess around with that for now.

However, @h4sh3d if you think that it makes sense to implement FromHex for PaymentId and Hash let me know and I'll do that :) although a drawback is that from_hex does not accept strings starting with 0x, so maybe having things as they are now is the best option.

@LeoNero
Copy link
Member Author

LeoNero commented Jul 13, 2022

@h4sh3d done

@LeoNero LeoNero requested a review from h4sh3d July 14, 2022 18:58
@h4sh3d
Copy link
Member

h4sh3d commented Jul 15, 2022

However, @h4sh3d if you think that it makes sense to implement FromHex for PaymentId and Hash let me know and I'll do that :) although a drawback is that from_hex does not accept strings starting with 0x, so maybe having things as they are now is the best option.

I think having FromHex implementation on some monero-rs types would be great. I agree that the 0x prefix is annoying. For now we should keep it like it is here.

Can you open an issue on monero-rs for FromHex implementation?

Copy link
Member

@h4sh3d h4sh3d left a comment

Choose a reason for hiding this comment

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

ACK

@h4sh3d h4sh3d merged commit 3e2682a into monero-rs:master Jul 15, 2022
refring pushed a commit to refring/monero-rpc-rs that referenced this pull request Oct 16, 2022
* feat(HashType)!: add AsRef as a trait bound, reimplemeting bytes()

* fix(HashType)!: fix HashType implementation for Vec<u8>

* docs(CHANGELOG): update CHANGELOG to reflect changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants