Skip to main content

Line

Struct Line 

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

A GPIO line opened on a Linux board, as an output or an input.

It implements the embedded-hal pin traits, so it goes under a Switch, a Contact, or any driver written against them, and Line::drive and Line::read work it directly.

Implementations§

Source§

impl Line

Source

pub fn chip(&self) -> &Path

The chip the line is on.

§Returns

The chip’s device file.

Source

pub fn offset(&self) -> u32

The line’s number on its chip.

§Returns

The offset it was opened at.

Source

pub fn drive(&mut self, level: Level) -> Result<(), LineError>

Drives the line to a level. The line must have been opened with output.

§Arguments
  • level - the level to drive.
§Errors

A LineError naming the line when the kernel refuses the write, which is what an input line answers.

Source

pub fn read(&mut self) -> Result<Level, LineError>

Reads the level on the line now.

§Returns

The level.

§Errors

A LineError naming the line when the kernel refuses the read.

Trait Implementations§

Source§

impl Debug for Line

Source§

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

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

impl ErrorType for Line

Source§

type Error = LineError

Error type
Source§

impl InputPin for Line

Source§

fn is_high(&mut self) -> Result<bool, LineError>

Is the input pin high?
Source§

fn is_low(&mut self) -> Result<bool, LineError>

Is the input pin low?
Source§

impl OutputPin for Line

Source§

fn set_low(&mut self) -> Result<(), LineError>

Drives the pin low. Read more
Source§

fn set_high(&mut self) -> Result<(), LineError>

Drives the pin high. Read more
§

fn set_state(&mut self, state: PinState) -> Result<(), Self::Error>

Drives the pin high or low depending on the provided value. Read more

Auto Trait Implementations§

§

impl Freeze for Line

§

impl RefUnwindSafe for Line

§

impl Send for Line

§

impl Sync for Line

§

impl Unpin for Line

§

impl UnsafeUnpin for Line

§

impl UnwindSafe for Line

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.