pub struct RegisterPoints { /* private fields */ }Expand description
A local cache of 16-bit register values mapped to their Modbus addresses.
Use apply_read to merge values returned by
ModbusClient::read_holding_registers.
Implementations§
Source§impl RegisterPoints
impl RegisterPoints
Sourcepub fn new(start_address: u16, count: usize) -> Self
pub fn new(start_address: u16, count: usize) -> Self
Create a new register cache with count registers starting at start_address, all initially 0.
Sourcepub fn from_values(start_address: u16, values: Vec<u16>) -> Self
pub fn from_values(start_address: u16, values: Vec<u16>) -> Self
Create a register cache from existing values.
Sourcepub fn start_address(&self) -> u16
pub fn start_address(&self) -> u16
The starting Modbus address of this cache.
Sourcepub fn get(&self, address: u16) -> Option<u16>
pub fn get(&self, address: u16) -> Option<u16>
Get the register value at the given Modbus address, or None if out of range.
Sourcepub fn set(&mut self, address: u16, value: u16) -> Result<(), ClientError>
pub fn set(&mut self, address: u16, value: u16) -> Result<(), ClientError>
Set the register value at the given Modbus address.
Sourcepub fn apply_read(
&mut self,
start_address: u16,
values: &[u16],
) -> Result<(), ClientError>
pub fn apply_read( &mut self, start_address: u16, values: &[u16], ) -> Result<(), ClientError>
Merge a batch of read values into this cache at the given start address.
Trait Implementations§
Source§impl Clone for RegisterPoints
impl Clone for RegisterPoints
Source§fn clone(&self) -> RegisterPoints
fn clone(&self) -> RegisterPoints
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RegisterPoints
impl Debug for RegisterPoints
Source§impl PartialEq for RegisterPoints
impl PartialEq for RegisterPoints
impl Eq for RegisterPoints
impl StructuralPartialEq for RegisterPoints
Auto Trait Implementations§
impl Freeze for RegisterPoints
impl RefUnwindSafe for RegisterPoints
impl Send for RegisterPoints
impl Sync for RegisterPoints
impl Unpin for RegisterPoints
impl UnsafeUnpin for RegisterPoints
impl UnwindSafe for RegisterPoints
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more