Re: [libgpiod][PATCH 5/5] bindings: rust: provide LineRequest::chip_path()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu Jul 20, 2023 at 10:04 AM CEST, Bartosz Golaszewski wrote:
> On Thu, Jul 20, 2023 at 7:04 AM Erik Schilling
> <erik.schilling@xxxxxxxxxx> wrote:
> >
> > On Wed Jul 19, 2023 at 9:20 PM CEST, Bartosz Golaszewski wrote:
> > > From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
> > >
> > > Provide a wrapper around gpiod_line_request_get_chip_path() for Rust
> > > bindings and add a test-case.
> > >
> > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
> > > ---
> > [...]
> > > diff --git a/bindings/rust/libgpiod/src/line_request.rs b/bindings/rust/libgpiod/src/line_request.rs
> > > index 1140aa9..2caab14 100644
> > > --- a/bindings/rust/libgpiod/src/line_request.rs
> > > +++ b/bindings/rust/libgpiod/src/line_request.rs
> > [...]
> > > @@ -25,6 +26,17 @@ impl Request {
> > >          Ok(Self { request })
> > >      }
> > >
> > > +    pub fn chip_path(&self) -> Result<&str> {
[...]
> > More importantly, _if_ this function is returning a file path, then I
> > would consider to return a Path [1]. The conversion from &str -> Path is
> > "0-cost" and makes the API more explicit. `Sim::dev_path()` also returns
> > a PathBuf so the conversion in the test would become a little easier.
> >
>
> I wanted to stay in line with chip's path() getter which also returns
> Result<&str>. As you're saying - the user can convert it at 0 cost if
> needed.

Makes sense. Did not notice that it is used as &str elsewhere.

- Erik




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux