pub fn new(addr: u16, registers: RegisterSlice<'a>) -> Result<Self, ModbusSerializationError> {
        match registers.len() {
            0 => Err(ModbusSerializationError::Invalid),
            n if n > 123 => Err(ModbusSerializationError::TooLarge),
            n if addr.overflowing_add(n as u16).1 => Err(ModbusSerializationError::Overflow),
            _ => Ok(unsafe { Self::new_unchecked(addr, registers) }),
        }
    }
/// Create a new request to write multiple registers.
///
/// # Errors
/// It is not allowed to write 0 or more than 123 registers. If you try to write 0 [ModbusSerializationError::Invalid]
/// will be returned.
/// If the len of registers exceeds 123 [ModbusSerializationError::TooLarge] will be returned.
/// [ModbusSerializationError::Overflow] will be returned if addr + registers.len() overflows the 0xFFFF boundary
Create a new request to write multiple registers.
Create a new request to write multiple registers .
pub fn new(addr: u16, registers: RegisterSlice<'a>) -> Result<Self, ModbusSerializationError> {
        match registers.len() {
            0 => Err(ModbusSerializationError::Invalid),
            n if n > 123 => Err(ModbusSerializationError::TooLarge),
            n if addr.overflowing_add(n as u16).1 => Err(ModbusSerializationError::Overflow),
            _ => Ok(unsafe { Self::new_unchecked(addr, registers) }),
        }
    }
pub fn new ( addr : u16 , registers : RegisterSlice < ' a > ) -> Result < Self , ModbusSerializationError > { match registers . len ( ) { 0 => Err ( ModbusSerializationError :: Invalid ) , n if n > 123 => Err ( ModbusSerializationError :: TooLarge ) , n if addr . overflowing_add ( n as u16 ) . 1 => Err ( ModbusSerializationError :: Overflow ) , _ => Ok ( unsafe { Self :: new_unchecked ( addr , registers ) } ) , } }
Create a new request to write multiple registers.
Create a new request to write multiple registers .
addr
u16
registers
RegisterSlice<'a>
addr
u16
registers
RegisterSlice<'a>
errors
It is not allowed to write 0 or more than 123 registers. If you try to write 0 [ModbusSerializationError::Invalid]
will be returned.
If the len of registers exceeds 123 [ModbusSerializationError::TooLarge] will be returned.
[ModbusSerializationError::Overflow] will be returned if addr + registers.len() overflows the 0xFFFF boundary
It is not allowed to write 0 or more than 123 registers . If you try to write 0 [ ModbusSerializationError :: Invalid ] will be returned . If the len of registers exceeds 123 [ ModbusSerializationError :: TooLarge ] will be returned . [ ModbusSerializationError :: Overflow ] will be returned if addr + registers . len () overflows the 0xFFFF boundary