Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Fix clippy lints and expose dependencies of API #34

Merged
merged 7 commits into from
Mar 18, 2022
Merged

Conversation

morrisonlevi
Copy link
Collaborator

What does this PR do?

Fix clippy lints and expose dependencies of API.

Motivation

hyper::Uri and chrono::{DateTime, Utc} are used in the public Rust API,
so we need to pub use them so consumers can use these types and for
them to be compatible.

Additional Notes

I don't have my POC that's using this API fully working yet, so there may be other needed changes, but at least these should be made.

hyper::Uri and chrono::{DateTime, Utc} are used in the public Rust API,
so we need to `pub use` them so consumers can use these types and for
them to be compatible.
0.1.4 uses const new, which requires Rust 1.57+
Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

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

Left two noob questions, but other than the gitlab-ci this looks to be in good shape :)

.gitlab-ci.yml Outdated
Comment on lines 4 to 6
DOWNSTREAM_BRANCH:
value: "main"
value: "levi/rust-1.56"
description: "downstream jobs are triggered on this branch"
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing this change should not go into the main branch :)

Copy link
Collaborator Author

@morrisonlevi morrisonlevi Mar 16, 2022

Choose a reason for hiding this comment

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

Correct -- this will get changed once the downstream PR is fixed and merged. Moved back to draft to reflect this.

Comment on lines 193 to +194
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.tcp.poll_ready(cx).map_err(|e| e.into())
self.tcp.poll_ready(cx)
Copy link
Member

Choose a reason for hiding this comment

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

My weak rust-foo is failing me here. Why is it ok to remove the error handling here now and but seems like it was needed before?

Copy link
Collaborator Author

@morrisonlevi morrisonlevi Mar 16, 2022

Choose a reason for hiding this comment

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

It's because the result of self.tcp.poll_ready(cx) is already type Poll<Result<(), Self::Error>> -- the code .map_err(|e| e.into()) is redundant.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks... To be honest I search the docs and could not confirm that was the type. Do you have any tips for looking up the types in these cases? Do you just use an IDE for that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In this case, clippy told me about it and I verified it in CLion, which is the IDE I use for C and Rust projects.

Copy link
Member

Choose a reason for hiding this comment

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

Guess it's time I setup CLion for libddprof >_>

Comment on lines 223 to +224
if let Some(path) = str.strip_prefix("unix://") {
return Ok(ddprof_exporter::socket_path_to_uri(path.as_ref())?);
return ddprof_exporter::socket_path_to_uri(path.as_ref());
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious -- why is the Ok not needed anymore? Is it assumed as the default on a return if you don't state it anywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

socket_path_to_uri already returns a Result -- there's no need to use ? and wrap it back into Ok ^_^

@morrisonlevi morrisonlevi marked this pull request as draft March 16, 2022 13:08
* Remove unused Exporter APIs and adjust Slices

CharSlice -> intended to be valid utf-8 string.
ByteSlice -> not intended to be valid utf-8 string (like binary data).

* Fix quoting for CMake

* Fix exporter example, address CR feedback
@morrisonlevi morrisonlevi marked this pull request as ready for review March 18, 2022 21:25
@morrisonlevi morrisonlevi merged commit bd2f759 into main Mar 18, 2022
@morrisonlevi morrisonlevi deleted the levi/clippy branch March 18, 2022 21:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants