Skip to content

Restructure icu_provider files #2168

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

Merged
merged 10 commits into from
Jul 18, 2022

Conversation

robertbastian
Copy link
Member

@robertbastian robertbastian commented Jul 12, 2022

These are some moves that I've been itching to do before #1576

  • resource.rs gets dissolved as it doesn't make sense as a module name after Implement naming convention for "data provider" #1576
    • ResourceOptions into request.rs (new)
    • ResourceKey, ResourceKeyHash into key.rs (new)
  • data_provider.rs, a 900-line file, gets split
    • DynProvider and ResourceProvider stay
    • DataRequest and DataRequestMetadata into request.rs (new)
    • DataResponse, DataResponseMetadata, DataPayload, RcWrap into response.rs (new)
    • data_provider/tests.rs are added here
  • marker/
    • impls.rs deleted, CowStrMarker usages replaced by HelloWorldV1Marker
    • mod.rs hoisted up as marker.rs

@robertbastian robertbastian marked this pull request as ready for review July 13, 2022 15:51
Manishearth
Manishearth previously approved these changes Jul 13, 2022
Manishearth
Manishearth previously approved these changes Jul 14, 2022
Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

I don't think this is a significant improvement over the status quo, but it's fine

I think the best way to lay these out would be to have one file for each type. ResourceKey, ResourceOptions, DataRequest, DataResponse, and DataPayload all in their own files.


/// Marker type for [`Cow`]`<str>` where the backing cart is `str`.
#[allow(clippy::exhaustive_structs)] // marker type
pub struct CowStrMarker;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: It does not make sense to have this in hello_world because it is not used by hello_world. I disagree that this is a "toy" implementation; it could very well be used by data structs that contain only a string.

Copy link
Member Author

Choose a reason for hiding this comment

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

It feels like one though. It's very easy for clients to write their own CowStrMarker, and do we actually want to provide a non-ResourceMarker DataMarker as a stable type? Also, why just CowStrMarker and not CowBytesMarker?

I'd also be happy with removing it.

Copy link
Member

Choose a reason for hiding this comment

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

I won't be heartbroken if you remove it, but anywhere it's used, we should migrate to something else. It is mostly used in docs tests. You can change those to something else like HelloWorldV1 if you prefer, or by re-defining CowStrMarker at each call site. However, namespacing it in hello_world is not correct.

Copy link
Member

Choose a reason for hiding this comment

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

Thought: CowStrMarker has convenience functions like DataPayload::<CowStrMarker>::from_static_str. You could achieve mostly the same goal by adding DataPayload::<HelloWorldV1Marker>::from_static_str or HelloWorldV1::from_static_str("...").into_data_payload()

@codecov-commenter
Copy link

Codecov Report

Merging #2168 (5d8b2a8) into main (5fa8537) will increase coverage by 0.01%.
The diff coverage is 89.60%.

@@            Coverage Diff             @@
##             main    #2168      +/-   ##
==========================================
+ Coverage   76.60%   76.61%   +0.01%     
==========================================
  Files         400      400              
  Lines       32578    32565      -13     
==========================================
- Hits        24955    24950       -5     
+ Misses       7623     7615       -8     
Impacted Files Coverage Δ
provider/core/src/any.rs 78.49% <ø> (ø)
provider/core/src/dynutil.rs 84.61% <ø> (ø)
provider/core/src/lib.rs 100.00% <ø> (ø)
provider/core/src/key.rs 87.20% <78.12%> (ø)
provider/core/src/request.rs 89.47% <89.47%> (ø)
provider/core/src/data_provider.rs 88.80% <89.68%> (+0.34%) ⬆️
provider/core/src/response.rs 93.40% <93.40%> (ø)
provider/core/src/hello_world.rs 94.52% <100.00%> (+0.23%) ⬆️
components/locid/src/parser/mod.rs 91.11% <0.00%> (-2.23%) ⬇️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5fa8537...5d8b2a8. Read the comment docs.

Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

LGTM except for the location of CowStrMarker

@robertbastian robertbastian requested a review from sffc July 18, 2022 16:40
sffc
sffc previously approved these changes Jul 18, 2022
sffc
sffc previously approved these changes Jul 18, 2022
@robertbastian robertbastian requested a review from sffc July 18, 2022 16:59
@robertbastian robertbastian merged commit d176e6d into unicode-org:main Jul 18, 2022
@robertbastian robertbastian deleted the restructure branch July 18, 2022 22:36
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