Struct gpiocdev::chip::Chip

source ·
pub struct Chip { /* private fields */ }
Expand description

A GPIO character device.

Implementations§

source§

impl Chip

source

pub fn from_path<P: AsRef<Path>>(p: P) -> Result<Chip>

Constructs a Chip using the given path.

The path must resolve to a valid GPIO character device.

§Examples
 let chip = gpiocdev::Chip::from_path("/dev/gpiochip0")?;
source

pub fn from_name(n: &str) -> Result<Chip>

Constructs a Chip using the given name.

The name must resolve to a valid GPIO character device.

§Examples
 let chip = gpiocdev::Chip::from_name("gpiochip0")?;
source

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

Get the information for the chip.

source

pub fn name(&self) -> String

Return the name of the chip.

This is based on the filename component of the resolved chip path, not the name from the Info, so it does not involve any system calls.

source

pub fn path(&self) -> &Path

Return the path of the chip.

source

pub fn find_line_info(&self, name: &str) -> Option<Info>

Find the info for the named line.

Returns the first matching line.

source

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

Get the information for a line on the chip.

source

pub fn line_info_iter(&self) -> Result<LineInfoIterator<'_>>

An iterator that returns the info for each line on the chip.

source

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

Add a watch for changes to the publicly available information on a line.

This is a null operation if there is already a watch on the line.

source

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

Remove a watch for changes to the publicly available information on a line.

This is a null operation if there is no existing watch on the line.

source

pub fn has_line_info_change_event(&self) -> Result<bool>

Check if the request has at least one info change event available to read.

source

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

Wait for an info change event to be available.

source

pub fn read_line_info_change_event(&self) -> Result<InfoChangeEvent>

Read a single line info change event from the chip.

Will block until an edge event is available.

source

pub fn info_change_events(&self) -> InfoChangeIterator<'_>

An iterator for info change events from the chip.

source

pub fn detect_abi_version(&self) -> Result<AbiVersion>

Detect the most recent uAPI ABI supported by the library for the chip.

source

pub fn supports_abi_version(&self, abiv: AbiVersion) -> Result<()>

Check if the platform and library support a specific ABI version.

source

pub fn using_abi_version(&mut self, abiv: AbiVersion) -> &mut Self

Set the ABI version to use for subsequent operations.

Trait Implementations§

source§

impl AsFd for Chip

source§

fn as_fd(&self) -> BorrowedFd<'_>

Borrows the file descriptor. Read more
source§

impl AsRawFd for Chip

source§

fn as_raw_fd(&self) -> i32

Extracts the raw file descriptor. Read more
source§

impl AsRef<Chip> for AsyncChip

source§

fn as_ref(&self) -> &Chip

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<Chip> for AsyncChip

source§

fn as_ref(&self) -> &Chip

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<Chip> for Chip

source§

fn as_ref(&self) -> &Chip

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Debug for Chip

source§

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

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

impl From<AsyncChip> for Chip

source§

fn from(c: AsyncChip) -> Chip

Converts to this type from the input type.
source§

impl From<AsyncChip> for Chip

source§

fn from(c: AsyncChip) -> Chip

Converts to this type from the input type.
source§

impl From<Chip> for AsyncChip

source§

fn from(c: Chip) -> AsyncChip

Converts to this type from the input type.
source§

impl From<Chip> for AsyncChip

source§

fn from(c: Chip) -> AsyncChip

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Chip

§

impl Send 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
§

impl<T> AsSource for T
where T: AsFd,

§

fn source(&self) -> BorrowedFd<'_>

Returns the borrowed file descriptor.
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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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>,

§

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

§

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more