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

[feature] Expose Report and ReportType #640

Merged
merged 1 commit into from
Jun 2, 2020

Conversation

woshilapin
Copy link
Contributor

@woshilapin woshilapin commented Jun 1, 2020

For moving some part of transit_model like apply_rules out of transit_model, we need to expose Report and ReportType. However, some variant enums of ReportType are really related to apply_rules itself, not to transit_model. So I changed ReportType into a trait/contract/interface instead of an enum. User needs to implement a type that conforms to this contract. I also moved Report and ReportType into their own module report.

See https://github.com/CanalTP/tartare-tools/pull/77 for how this new trait will be used. In the current PR, one implementation of the new trait ReportType is TransitModelReportType which is nothing else than the old enum ReportType.

src/report.rs Outdated

impl<R: ReportType> Report<R> {
/// Creates an empty new report.
pub fn new() -> Self {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why not implementing Default manually instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in dac6b6a.

src/report.rs Outdated

/// Each report record will be categorized with a type implementing this
/// `ReportType` trait.
pub trait ReportType: Serialize + PartialEq {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Name the trait with a verb instead of a name.

At the very least ReportCategory is better (Type is connoted in Rust).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 7e0410e.

@ArnaudOggy ArnaudOggy merged commit 12a39e4 into hove-io:master Jun 2, 2020
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.

3 participants