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

refactor(iroh-bytes): Simplify store traits #2023

Merged
merged 8 commits into from
Feb 20, 2024
Merged

Conversation

rklaehn
Copy link
Contributor

@rklaehn rklaehn commented Feb 13, 2024

Description

Simplify and rename some store traits, taking advantage of return position impl trait in trait.

The main change is that the map entries are no longer for one specific map impl, but just generic map entries, so the type parameter goes away. Other than that, the PartialXXX traits are renamed to XXXMut, which is more accurate. An immutable entry can be partial. Since MapEntry does not guarantee that it is complete (anymore), the main difference between MapEntry and MapEntryMut is not that the latter allows writing.

Edit: one additional change is to introduce BaoBlobSize, which is a size together with an information about whether the size is validated or not. Why not just (u64, bool)? Because later we might add more info to the unverified enum case.

Notes & open questions

Note: this is not the end of it. Just trying to do this incrementally.

Change checklist

  • Self-review.
  • Documentation updates if relevant.
  • Tests if relevant.

PartialMap -> MapMut
PartialEntry -> EntryMut
@rklaehn rklaehn changed the title Simplify store triat Simplify store trait Feb 19, 2024
@rklaehn rklaehn force-pushed the simplify-store-triat branch from d9ea292 to bee6d19 Compare February 19, 2024 09:31
@rklaehn rklaehn changed the title Simplify store trait refactor(iroh-bytes): Simplify store traits Feb 19, 2024
@rklaehn rklaehn force-pushed the simplify-store-triat branch from bee6d19 to 8ef2bc3 Compare February 19, 2024 10:13
# Conflicts:
#	iroh-net/src/netcheck/reportgen.rs
@rklaehn rklaehn force-pushed the simplify-store-triat branch from 8ef2bc3 to ebd58f5 Compare February 19, 2024 10:30
@dignifiedquire dignifiedquire added this to the v0.13.0 milestone Feb 19, 2024
in particular clarify what a Map is.
for now this is an enum with a size and verified/unverified. In the future
we might add more info to the unverified path, such as the max offset
we have validated. But this info is not always available easily, so we
don't for now.

If you just want the size value, there is .value().
@rklaehn rklaehn requested a review from Frando February 20, 2024 07:37
@rklaehn rklaehn marked this pull request as ready for review February 20, 2024 09:25
Copy link
Member

@Frando Frando left a comment

Choose a reason for hiding this comment

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

👍 Nothing stood out to me, apart from the already resolved question of whether we want to use RPITIT - where I think I agree with rklaehn's reasoning above that you usually will need lots of boilerplate or boxing anyways. And the code reads much nicer with the impl Trait than with the associated traits. So: LGTM!

@rklaehn rklaehn added this pull request to the merge queue Feb 20, 2024
Merged via the queue into main with commit 27a8ef1 Feb 20, 2024
20 checks passed
fubuloubu pushed a commit to ApeWorX/iroh that referenced this pull request Feb 21, 2024
## Description

Simplify and rename some store traits, taking advantage of return
position impl trait in trait.

The main change is that the map entries are no longer for one specific
map impl, but just generic map entries, so the type parameter goes away.
Other than that, the PartialXXX traits are renamed to XXXMut, which is
more accurate. An immutable entry can be partial. Since MapEntry does
not guarantee that it is complete (anymore), the main difference between
MapEntry and MapEntryMut is not that the latter allows writing.

Edit: one additional change is to introduce BaoBlobSize, which is a size
together with an information about whether the size is validated or not.
Why not just (u64, bool)? Because later we might add more info to the
unverified enum case.

## Notes & open questions

Note: this is not the end of it. Just trying to do this incrementally.

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
- [ ] Tests if relevant.
@rklaehn rklaehn deleted the simplify-store-triat branch April 10, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants