Hi Viresh,
On Wed, Nov 3, 2021 at 6:03 AM Viresh Kumar viresh.kumar@linaro.org wrote:
Here is another attempt to add rust wrappers for libgpiod, hopefully it would look much better this time.
From a quick look, it does look way better!
- Propagate proper errors returned by the kernel to the user. Improved error handling overall.
I see you are using `ThisError`, nice! :)
- Improved Enum support, with their own helpers to reduce redundant code.
The new enums look much cleaner (e.g. `Direction::`) -- thanks for using that recommendation.
- SAFETY comments added to methods that return strings.
Note that these should be in the body, as a normal comment right before `unsafe` blocks explaining why the block is sound, e.g.:
// SAFETY: `x` is dereferencable by the type invariants. unsafe { *x }
I think you are confusing them with the ones in the function documentation, which are a Markdown section (`#`) used in unsafe functions to explain the preconditions on the caller:
/// Does foo and bar /// /// # Safety /// /// `x` must be a multiple of 2. unsafe fn f(x: u32) { // ... }
Cheers, Miguel