Struct Chip

Source
pub struct Chip { /* private fields */ }
Expand description

GPIO chip

A GPIO chip object is associated with an open file descriptor to the GPIO character device. It exposes basic information about the chip and allows callers to retrieve information about each line, watch lines for state changes and make line requests.

Implementations§

Source§

impl Chip

Source

pub fn open<P: AsRef<Path>>(path: &P) -> Result<Self>

Find a chip by path.

Source

pub fn info(&self) -> Result<Info>

Get the chip name as represented in the kernel.

Source

pub fn path(&self) -> Result<&str>

Get the path used to find the chip.

Source

pub fn line_info(&self, offset: Offset) -> Result<Info>

Get a snapshot of information about the line.

Source

pub fn watch_line_info(&self, offset: Offset) -> Result<Info>

Get the current snapshot of information about the line at given offset and start watching it for future changes.

Source

pub fn unwatch(&self, offset: Offset)

Stop watching a line

Source

pub fn wait_info_event(&self, timeout: Option<Duration>) -> Result<bool>

Wait for line status events on any of the watched lines on the chip.

Source

pub fn read_info_event(&self) -> Result<Event>

Read a single line status change event from the chip. If no events are pending, this function will block.

Source

pub fn line_offset_from_name(&self, name: &str) -> Result<Offset>

Map a GPIO line’s name to its offset within the chip.

Source

pub fn request_lines( &self, rconfig: Option<&Config>, lconfig: &Config, ) -> Result<Request>

Request a set of lines for exclusive usage.

Trait Implementations§

Source§

impl AsRawFd for Chip

Source§

fn as_raw_fd(&self) -> i32

Get the file descriptor associated with the chip.

The returned file descriptor must not be closed by the caller, else other methods for the struct Chip may fail.

Source§

impl Debug for Chip

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Chip

Source§

fn drop(&mut self)

Close the chip and release all associated resources.

Source§

impl PartialEq for Chip

Source§

fn eq(&self, other: &Chip) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Chip

Source§

impl Send for Chip

Source§

impl StructuralPartialEq for Chip

Auto Trait Implementations§

§

impl Freeze for Chip

§

impl RefUnwindSafe for Chip

§

impl !Sync for Chip

§

impl Unpin for Chip

§

impl UnwindSafe for Chip

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, 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.