Struct GpioHandler

Source
pub struct GpioHandler {}
Expand description

Contains the configuration and the implementation for the GPIO handler.

Implementations§

Source§

impl GpioHandler

Source

pub fn check_valid_gpio_pin_config( config: &GpioHandlerConfig, ) -> Result<(), GpioHandlerError>

Checks if the GPIO pin configuration is valid and free from conflicts.

This function performs two essential validation checks on the configured GPIO pins:

  1. Range Check: Ensures all pins fall within the permissible operating range defined by GPIO_MIN and GPIO_MAX.
  2. Uniqueness Check: Verifies that all assigned pins are distinct, preventing multiple devices from being configured to the same physical pin.
§Arguments
  • config - The GpioHandlerConfig struct containing the GPIO pin assignments.
§Returns

An empty Result (Ok(())) if all GPIO pins are valid.

§Errors

Returns a GpioHandlerError if any validation check fails:

  • GpioHandlerError::PinOutsideRange: If any configured GPIO pin is outside the valid range (e.g., less than or equal to 3, or greater than or equal to 28).
  • GpioHandlerError::PinDuplicateValue: If the same GPIO pin is assigned to more than one device.
Source

pub fn new( config: GpioHandlerConfig, ) -> Result<Option<GpioHandler>, GpioHandlerError>

Creates a new GpioHandler instance for development or non-target platforms.

This constructor is activated when compiling for a non-Linux OS or when the target_hw feature is disabled. It allows the application to run in a simulated mode without requiring real GPIO hardware.

§Arguments
  • config - Configuration data for the GPIO handler.
§Returns

A Result containing Ok(None) if the configuration is valid and use_simulator is true, indicating that no hardware handle is needed.

§Errors

Returns a GpioHandlerError if initialization fails:

  • GpioHandlerError::PlatformNotSupported: If use_simulator is false, as hardware access is not possible on the current platform.
  • GpioHandlerError::PinOutsideRange or PinDuplicateValue: If the pin configuration is invalid (propagated from check_valid_gpio_pin_config)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T