Enum RequestForm

Source
pub enum RequestForm<'a> {
    ReadHoldingRegisters {
        start_register: u16,
        registers_count: u16,
    },
    ReadInputRegisters {
        start_register: u16,
        registers_count: u16,
    },
    WriteSingleRegister {
        register_address: u16,
        data_to_write: u16,
    },
    WriteMultipleRegisters {
        start_register: u16,
        data_to_write: &'a [u16],
    },
    BypassRequest(&'a BypassRequest<'a>),
}
Expand description

Modbus RTU request packet format

Variants§

§

ReadHoldingRegisters

Request format for reading multiple Holding Registers

  • start_register: The starting register address
  • registers_count: The number of registers to read

Fields

§start_register: u16
§registers_count: u16
§

ReadInputRegisters

Request format for reading multiple Input Registers

  • start_register: The starting register address
  • registers_count: The number of registers to read

Fields

§start_register: u16
§registers_count: u16
§

WriteSingleRegister

Request format for writing a single Holding Register

  • register_address: The register address to write to
  • data_to_write: The data value to write

Fields

§register_address: u16
§data_to_write: u16
§

WriteMultipleRegisters

Request format for writing multiple Holding Registers

  • start_register: The starting register address
  • data_to_wirte: Slice of data values to write to consecutive registers

Fields

§start_register: u16
§data_to_write: &'a [u16]
§

BypassRequest(&'a BypassRequest<'a>)

Request format for bypassing a packet to a downstream device

Implementations§

Source§

impl<'a> RequestForm<'a>

Source

pub fn get_function_code(&self) -> u8

Retrieves the Modbus function code corresponding to the request form variant.


§Returns

A u8 representing the Modbus function code of the request.


§Examples
use modbus_rtu::common::RequestForm;

let form = RequestForm::ReadHoldingRegisters {
    start_register: 0x0000,
    registers_count: 2,
};

assert_eq!(form.get_function_code(), 0x03);

Trait Implementations§

Source§

impl<'a> Clone for RequestForm<'a>

Source§

fn clone(&self) -> RequestForm<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for RequestForm<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for RequestForm<'a>

§

impl<'a> RefUnwindSafe for RequestForm<'a>

§

impl<'a> Send for RequestForm<'a>

§

impl<'a> Sync for RequestForm<'a>

§

impl<'a> Unpin for RequestForm<'a>

§

impl<'a> UnwindSafe for RequestForm<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.