RegisterOperation

Struct RegisterOperation 

Source
pub struct RegisterOperation<'i, Interface, AddressType: Copy, Register: FieldSet, Access> { /* private fields */ }
Expand description

Object that performs actions on the device in the context of a register

Implementations§

Source§

impl<Interface, AddressType: Copy, Register: FieldSet, Access> RegisterOperation<'_, Interface, AddressType, Register, Access>
where Interface: RegisterInterface<AddressType = AddressType>, Access: WriteCapability,

Source

pub fn write<R>( &mut self, f: impl FnOnce(&mut Register) -> R, ) -> Result<R, Interface::Error>

Write to the register.

The closure is given the write object initialized to the reset value of the register. If no reset value is specified for this register, this function is the same as Self::write_with_zero.

Source

pub fn write_with_zero<R>( &mut self, f: impl FnOnce(&mut Register) -> R, ) -> Result<R, Interface::Error>

Write to the register.

The closure is given the write object initialized to all zero.

Source§

impl<Interface, AddressType: Copy, Register: FieldSet, Access> RegisterOperation<'_, Interface, AddressType, Register, Access>
where Interface: RegisterInterface<AddressType = AddressType>, Access: ReadCapability,

Source

pub fn read(&mut self) -> Result<Register, Interface::Error>

Read the register from the device

Source§

impl<Interface, AddressType: Copy, Register: FieldSet, Access> RegisterOperation<'_, Interface, AddressType, Register, Access>
where Interface: RegisterInterface<AddressType = AddressType>, Access: ReadCapability + WriteCapability,

Source

pub fn modify<R>( &mut self, f: impl FnOnce(&mut Register) -> R, ) -> Result<R, Interface::Error>

Modify the existing register value.

The register is read, the value is then passed to the closure for making changes. The result is then written back to the device.

Source§

impl<Interface, AddressType: Copy, Register: FieldSet, Access> RegisterOperation<'_, Interface, AddressType, Register, Access>
where Interface: AsyncRegisterInterface<AddressType = AddressType>, Access: WriteCapability,

Source

pub async fn write_async<R>( &mut self, f: impl FnOnce(&mut Register) -> R, ) -> Result<R, Interface::Error>

Write to the register.

The closure is given the write object initialized to the reset value of the register. If no reset value is specified for this register, this function is the same as Self::write_with_zero.

Source

pub async fn write_with_zero_async<R>( &mut self, f: impl FnOnce(&mut Register) -> R, ) -> Result<R, Interface::Error>

Write to the register.

The closure is given the write object initialized to all zero.

Source§

impl<Interface, AddressType: Copy, Register: FieldSet, Access> RegisterOperation<'_, Interface, AddressType, Register, Access>
where Interface: AsyncRegisterInterface<AddressType = AddressType>, Access: ReadCapability,

Source

pub async fn read_async(&mut self) -> Result<Register, Interface::Error>

Read the register from the device

Source§

impl<Interface, AddressType: Copy, Register: FieldSet, Access> RegisterOperation<'_, Interface, AddressType, Register, Access>
where Interface: AsyncRegisterInterface<AddressType = AddressType>, Access: ReadCapability + WriteCapability,

Source

pub async fn modify_async<R>( &mut self, f: impl FnOnce(&mut Register) -> R, ) -> Result<R, Interface::Error>

Modify the existing register value.

The register is read, the value is then passed to the closure for making changes. The result is then written back to the device.

Auto Trait Implementations§

§

impl<'i, Interface, AddressType, Register, Access> Freeze for RegisterOperation<'i, Interface, AddressType, Register, Access>
where AddressType: Freeze,

§

impl<'i, Interface, AddressType, Register, Access> RefUnwindSafe for RegisterOperation<'i, Interface, AddressType, Register, Access>
where AddressType: RefUnwindSafe, Interface: RefUnwindSafe, Register: RefUnwindSafe, Access: RefUnwindSafe,

§

impl<'i, Interface, AddressType, Register, Access> Send for RegisterOperation<'i, Interface, AddressType, Register, Access>
where AddressType: Send, Interface: Send, Register: Send, Access: Send,

§

impl<'i, Interface, AddressType, Register, Access> Sync for RegisterOperation<'i, Interface, AddressType, Register, Access>
where AddressType: Sync, Interface: Sync, Register: Sync, Access: Sync,

§

impl<'i, Interface, AddressType, Register, Access> Unpin for RegisterOperation<'i, Interface, AddressType, Register, Access>
where AddressType: Unpin, Register: Unpin, Access: Unpin,

§

impl<'i, Interface, AddressType, Register, Access> !UnwindSafe for RegisterOperation<'i, Interface, AddressType, Register, Access>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.