Re: [PATCH V6 3/8] libgpiod: Add rust wrapper crate

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

 



On 14-10-22, 11:45, Bartosz Golaszewski wrote:
> Maybe also add chained mutators everywhere? To be able to do
> settings.set_direction().set_edge() etc.?

Based on Kent's suggestion earlier, what I have implemented is
set_prop(), to which one can pass all settings and it will apply them
in a loop.

    pub fn set_prop(&mut self, values: &[SettingVal]) -> Result<()> {
        for value in values {
            match value {
                SettingVal::Direction(val) => self.set_direction(*val)?,
                SettingVal::EdgeDetection(val) => self.set_edge_detection(*val)?,
                SettingVal::Bias(val) => self.set_bias(*val)?,
                SettingVal::Drive(val) => self.set_drive(*val)?,
                SettingVal::ActiveLow(val) => self.set_active_low(*val),
                SettingVal::DebouncePeriod(val) => self.set_debounce_period(*val),
                SettingVal::EventClock(val) => self.set_event_clock(*val)?,
                SettingVal::OutputValue(val) => self.set_output_value(*val)?,
            }
        }

        Ok(())
    }

I think that replaces the need of nested ones ? And if we want to add
those later, we can always come back and add them. But I am not sure
it would be required.

> And I would still love a thorough API review from someone who actually
> knows rust too. :(

Well, Kent did a very good job earlier. I am not sure if he has extra
cycles to review this once again, though not a lot has changed since
last time.

> But I will play some more with v7 so do send it.

Great.

-- 
viresh



[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