-
Notifications
You must be signed in to change notification settings - Fork 346
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
Adopt thiserror
for libcgroups
#1872
Conversation
Signed-off-by: squili <74628488+squili@users.noreply.github.com>
Signed-off-by: squili <74628488+squili@users.noreply.github.com>
Signed-off-by: squili <74628488+squili@users.noreply.github.com>
Signed-off-by: squili <74628488+squili@users.noreply.github.com>
Signed-off-by: squili <74628488+squili@users.noreply.github.com>
Signed-off-by: squili <74628488+squili@users.noreply.github.com>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1872 +/- ##
==========================================
- Coverage 68.89% 68.13% -0.77%
==========================================
Files 122 122
Lines 13717 14011 +294
==========================================
+ Hits 9450 9546 +96
- Misses 4267 4465 +198 |
Signed-off-by: squili <74628488+squili@users.noreply.github.com>
Signed-off-by: squili <74628488+squili@users.noreply.github.com>
Signed-off-by: squili <74628488+squili@users.noreply.github.com>
Signed-off-by: squili <74628488+squili@users.noreply.github.com>
Signed-off-by: squili <74628488+squili@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/// Parses a file that is structed according to the nested keyed format | ||
/// # Example | ||
/// ``` | ||
/// use libcgroups::stats::parse_device_number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to keep the example here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example was triggering doctets, which then failed because the function was made crate-only
#[error("failed to read {path}: {err}")] | ||
Read { err: std::io::Error, path: PathBuf }, | ||
#[error("failed to create dir {path}: {err}")] | ||
CreateDir { err: std::io::Error, path: PathBuf }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this WrappedIoError idea ❤️
If the dirs cannot be created in the libcgroup crates, does this result in the failure to create a new cgroup?
I believe it is more user-friendly to display a message such as "failed to create the cgroup" or something similar. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what errors higher up in the chain are for - they can be added to the higher-level error adts with more user-friendly messages
@@ -1,6 +1,6 @@ | |||
use std::fmt::Display; | |||
|
|||
#[derive(Hash, PartialEq, Eq, Debug, Clone)] | |||
#[derive(Hash, PartialEq, Eq, Debug, Clone, Copy)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need Copy
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This enum is essentially just a fancy number, so the performance of passing by reference and copying are the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifically, this allows us to do *controller_type
instead of controller_type.clone()
to turn a reference into an owned value
It looks like that lint said the error. Please check them 🙏 |
Signed-off-by: squili <74628488+squili@users.noreply.github.com>
Signed-off-by: squili <74628488+squili@users.noreply.github.com>
Signed-off-by: squili <74628488+squili@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
I can't believe that you make this PR in such a short period of time 😲
As prescribed in #1377