pub struct Registers<const N: usize = MAX_REGISTERS_PER_PDU> { /* private fields */ }Expand description
Represents the state of a block of registers read from a Modbus server.
This structure maintains the starting address and the quantity of registers, providing safe accessors to individual values within the block.
§Type Parameters
N- The internal storage capacity, defaults toMAX_REGISTERS_PER_PDU.
Implementations§
Source§impl<const N: usize> Registers<N>
impl<const N: usize> Registers<N>
Sourcepub fn new(from_address: u16, quantity: u16) -> Result<Self, MbusError>
pub fn new(from_address: u16, quantity: u16) -> Result<Self, MbusError>
Creates a new Registers instance.
§Arguments
from_address- The starting Modbus address.quantity- The number of registers to be managed in this block.
Sourcepub fn with_values(self, values: &[u16], length: u16) -> Result<Self, MbusError>
pub fn with_values(self, values: &[u16], length: u16) -> Result<Self, MbusError>
Loads register values into the model and validates the length against capacity.
§Arguments
values- A slice of 16-bit values to copy into the internal buffer.length- The number of registers being loaded.
Sourcepub fn from_address(&self) -> u16
pub fn from_address(&self) -> u16
Returns the starting Modbus address of the first register.
Trait Implementations§
impl<const N: usize> Eq for Registers<N>
impl<const N: usize> StructuralPartialEq for Registers<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for Registers<N>
impl<const N: usize> RefUnwindSafe for Registers<N>
impl<const N: usize> Send for Registers<N>
impl<const N: usize> Sync for Registers<N>
impl<const N: usize> Unpin for Registers<N>
impl<const N: usize> UnsafeUnpin for Registers<N>
impl<const N: usize> UnwindSafe for Registers<N>
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