[][src]Struct apigpio::Connection

pub struct Connection { /* fields omitted */ }

The main struct which owns a connection to pigpiod. Start by creating one of these.

Most of the interesting methods are methods on ConnectionCore which this derefs to.

Methods

impl Connection[src]

pub async fn new_at<'_, A: ToSocketAddrs>(addr: &'_ A) -> Result<Connection>[src]

Connects to pigpiod, given specific socket address details.

pub async fn new() -> Result<Connection>[src]

Connects to pigpiod using the default address and port.

impl Connection[src]

pub async fn notify_subscribe<'_>(
    &'_ self,
    pin: Pin,
    read_initially: bool,
    tick_keepalives: bool
) -> Result<Subscription>
[src]

Starts watching for changes to a GPIO pin. Change notifications are sent as GpioChange to the returned Subscription, which is a wrapper for a watch::Receiver<GpioChange>.

If read_initially, reads the gpio once at the start, so that the subscription's level starts out as Some.

If tick_keepalives, will send a GpioChange with unchanged Some(Level) and a fresh Some(Tick) at least every TICK_KEEPALIVE_US; this allows the receiver to spot when the tick wraps around.

Behind the scenes, getting GPIO change notifications involves making a 2nd connection to pigpiod. This will be done the first time notify_subscribe is called; it will then be retained for future reuse. This is relevant to Rust callers because pigpiod has a limit on the number of simultaneous connections.

Methods from Deref<Target = ConnectionCore>

pub async fn set_mode<'_>(&'_ self, pin: Pin, mode: GpioMode) -> Result<()>[src]

pub async fn get_mode<'_>(&'_ self, pin: Pin) -> Result<GpioMode>[src]

pub async fn set_pull_up_down<'_>(
    &'_ self,
    pin: Word,
    pud: PullUpDown
) -> Result<()>
[src]

pub async fn gpio_read<'_>(&'_ self, pin: Pin) -> Result<Level>[src]

pub async fn gpio_write<'_>(&'_ self, pin: Pin, level: Level) -> Result<()>[src]

pub async fn wave_clear<'_>(&'_ self) -> Result<()>[src]

pub async fn wave_add_new<'_>(&'_ self) -> Result<WaveId>[src]

pub async fn wave_create<'_>(&'_ self) -> Result<WaveId>[src]

Caller is responsible for not calling wave_* functions for multiple purposes concurrently - ie, for enforcing the concurrency control implied by pigpiod's interface.

Getting this wrong is not a memory safety concern (hence the lack of unsafe) but would cause wrong behaviours.

Note that this applies even across multiple different pigpiod clients.

pub async unsafe fn wave_delete<'_>(&'_ self, wave: WaveId) -> Result<()>[src]

This is safe if no-one in the whole system ever calls wave_send_using_mode with mode *SYNC*. See the pigpio documentation on wave_send_using_mode for full details.

pub async fn wave_send_once<'_>(&'_ self, wave: WaveId) -> Result<Word>[src]

pub async fn wave_send_repeat<'_>(&'_ self, wave: WaveId) -> Result<Word>[src]

pub async fn wave_tx_stop<'_>(&'_ self) -> Result<()>[src]

pub async fn wave_tx_at<'_>(&'_ self) -> Result<Option<WaveId>>[src]

pub async fn wave_tx_busy<'_>(&'_ self) -> Result<bool>[src]

pub async fn wave_add_generic<'_, '_>(
    &'_ self,
    pulses: &'_ [Pulse]
) -> Result<Word>
[src]

pub async fn wave_get_micros<'_>(&'_ self) -> Result<Word>[src]

pub async fn wave_get_high_micros<'_>(&'_ self) -> Result<Word>[src]

pub async fn wave_get_max_micros<'_>(&'_ self) -> Result<Word>[src]

pub async unsafe fn wave_send_using_mode<'_>(
    &'_ self,
    wave: WaveId,
    txmode: Word
) -> Result<Word>
[src]

Caller must ensure that if txmode is *SYNC* the "bad things" described in the pigpio docs do not happen.

If any calls to this function use *SYNC*, then wave_delete is potentially unsafe and all calls to it must be checked.

Note that because everything is shared amongst all clients of pigpiod, this might involve auditing your process handling etc.

Caller must also ensure that txmode is a valid value. If it is not then possibly it invokes some hazardous new feature of pigpiod.

Trait Implementations

impl Clone for Connection[src]

impl Deref for Connection[src]

type Target = ConnectionCore

The resulting type after dereferencing.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.