RcDevice

Struct RcDevice 

Source
pub struct RcDevice<Bus> { /* private fields */ }
Available on crate features std or alloc only.
Expand description

Rc<RefCell<T>>-based shared bus I2c implementation. This is the reference-counting equivalent of RefCellDevice.

Sharing is implemented with a RefCell and ownership is managed by Rc. Like RefCellDevice, RcDevice instances are not Send, so they can only be shared within a single thread (interrupt priority level).

When this RcDevice is dropped, the reference count of the I2C bus will be decremented. Once that reference count hits zero, it will be cleaned up.

Implementations§

Source§

impl<Bus> RcDevice<Bus>

Source

pub fn new(bus: Rc<RefCell<Bus>>) -> Self

Available on crate feature alloc only.

Creates a new RcDevice.

This function does not increment the reference count for the bus: you will need to call Rc::clone(&bus) if you only have a &Rc<RefCell<Bus>>.

Trait Implementations§

Source§

impl<Bus> ErrorType for RcDevice<Bus>
where Bus: ErrorType,

Available on crate feature alloc only.
Source§

type Error = <Bus as ErrorType>::Error

Error type
Source§

impl<Bus> I2c for RcDevice<Bus>
where Bus: I2c,

Available on crate feature alloc only.
Source§

fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error>

Reads enough bytes from slave with address to fill read. Read more
Source§

fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error>

Writes bytes to slave with address address. Read more
Source§

fn write_read( &mut self, address: u8, write: &[u8], read: &mut [u8], ) -> Result<(), Self::Error>

Writes bytes to slave with address address and then reads enough bytes to fill read in a single transaction. Read more
Source§

fn transaction( &mut self, address: u8, operations: &mut [Operation<'_>], ) -> Result<(), Self::Error>

Execute the provided operations on the I2C bus. Read more

Auto Trait Implementations§

§

impl<Bus> Freeze for RcDevice<Bus>

§

impl<Bus> !RefUnwindSafe for RcDevice<Bus>

§

impl<Bus> !Send for RcDevice<Bus>

§

impl<Bus> !Sync for RcDevice<Bus>

§

impl<Bus> Unpin for RcDevice<Bus>

§

impl<Bus> !UnwindSafe for RcDevice<Bus>

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.