zephyr::device::gpio

Struct GpioToken

Source
pub struct GpioToken(/* private fields */);
Expand description

Global instance to help make gpio in Rust slightly safer.

§Safety

To help with safety, the rust types use a global instance of a gpio-token. Methods will take a mutable reference to this, which will require either a single thread in the application code, or something like a mutex or critical section to manage. The operation methods are still unsafe, because we have no control over what happens with the gpio operations outside of Rust code, but this will help make the Rust usage at least better.

Implementations§

Source§

impl GpioToken

Source

pub unsafe fn get_instance() -> Option<GpioToken>

Retrieves the gpio token.

§Safety

This is unsafe because lots of code in zephyr operates on the gpio drivers. The user of the gpio subsystem, in general should either coordinate all gpio access across the system (the token coordinates this only within Rust code), or verify that the particular gpio driver and methods are thread safe.

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