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

SATA link speeds #453

Merged
merged 5 commits into from
Feb 20, 2025
Merged

SATA link speeds #453

merged 5 commits into from
Feb 20, 2025

Conversation

peterdk
Copy link
Contributor

@peterdk peterdk commented Feb 19, 2025

Expanded a bit on the PCIe Link code to also support SATA speeds.

It was quite hard to get the actual ata_link property from sysfs. The only way I could find to get the ata device and then link was through reading the actual symlink for a /sys/class/block/x device and then finding the \ataXX\ path and then the linkXX subdir of it. Which is somewhat hacky, but I am also too novice in Rust to make it less verbose. So feel free to suggest some changes there.

I added a dependency, which seemed lightweight. It is used to be able to navigate to a joined Path with ../../ from the symlink in it.

@peterdk
Copy link
Contributor Author

peterdk commented Feb 19, 2025

Screenshot From 2025-02-19 19-46-51

@nokyan
Copy link
Owner

nokyan commented Feb 20, 2025

Hi, thanks a lot, that's really cool and works really well!

I managed to make a few code segments more compact, I hope you don't mind that I pushed it to your branch. :)
Those segments were mostly error handling, function chaining and using generics for &PathBuf and &str.

Are you fine with that?

@peterdk
Copy link
Contributor Author

peterdk commented Feb 20, 2025

Ah cool, this and_then() stuff is interesting! And nice to put the regexes as single init constants.

Yeah very nice! Thanks.

@peterdk
Copy link
Contributor Author

peterdk commented Feb 20, 2025

I'll look into adding USB link info in a following PR. Seems also quite easy, and then I think the most important Link types are present.

@nokyan
Copy link
Owner

nokyan commented Feb 20, 2025

I'll look into adding USB link info in a following PR. Seems also quite easy, and then I think the most important Link types are present.

Sounds nice, looking forward to it!

@nokyan nokyan merged commit ac4cb1c into nokyan:main Feb 20, 2025
1 check passed
@peterdk
Copy link
Contributor Author

peterdk commented Feb 20, 2025

So could you explain why the Generics for PathBuf? And why the &str use with Path.as_ref()?

@nokyan
Copy link
Owner

nokyan commented Feb 20, 2025

So could you explain why the Generics for PathBuf? And why the &str use with Path.as_ref()?

It doesn't functionally change anything but allows anything that by referencing it can be turned to a &str or Path to be used with the function. Makes reusing the function more ergonomic in cases. For example, a function that accepts AsRef<str> can take a String, &String or &str as an argument without the caller needing to do anything.
The .as_ref() call is defined in the AsRef<T> trait and turns whatever type has been supplied to the function to &str or Path.

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.

2 participants