Parses the `--gpio-pins` flag value and constructs the pins backend.
(spec: Option<&str>)
| 36 | |
| 37 | /// Parses the `--gpio-pins` flag value and constructs the pins backend. |
| 38 | pub(crate) fn setup_gpio_pins(spec: Option<&str>) -> Result<Rc<RefCell<dyn gpio::Pins>>> { |
| 39 | let spec = if cfg!(feature = "rpi") { spec.unwrap_or("rppal") } else { spec.unwrap_or("noop") }; |
| 40 | match spec { |
| 41 | "mock" => Ok(Rc::new(RefCell::new(gpio::MockPins::default()))), |
| 42 | "noop" => Ok(Rc::new(RefCell::new(gpio::NoopPins::default()))), |
| 43 | "rppal" => setup_gpio_pins_rppal(), |
| 44 | other => Err(bad_usage!(format!("Unknown --gpio-pins backend: {}", other)).into()), |
| 45 | } |
| 46 | } |
no test coverage detected