Skip to main content

SubRequest

Struct SubRequest 

Source
pub struct SubRequest { /* private fields */ }
Expand description

Represents a collection of sub-requests for Modbus File Record operations.

A single Modbus PDU for FC 0x14 or 0x15 can contain multiple sub-requests, allowing the client to read from or write to different files and records in one transaction.

This struct manages the aggregation of these requests and performs validation to ensure the resulting PDU does not exceed the Modbus protocol limit of 253 bytes.

Implementations§

Source§

impl SubRequest

Source

pub fn new() -> Self

Creates a new empty SubRequest.

Source

pub fn add_read_sub_request( &mut self, file_number: u16, record_number: u16, record_length: u16, ) -> Result<(), MbusError>

Adds a sub-request for reading a file record.

§Arguments
  • file_number - The file number.
  • record_number - The starting record number.
  • record_length - The number of registers to read.
Source

pub fn add_write_sub_request( &mut self, file_number: u16, record_number: u16, record_length: u16, record_data: Vec<u16, MAX_PDU_DATA_LEN>, ) -> Result<(), MbusError>

Adds a sub-request for writing a file record.

§Arguments
  • file_number - The file number.
  • record_number - The starting record number.
  • record_length - The number of registers to write.
  • record_data - The data to write.
Source

pub fn byte_count(&self) -> usize

Calculates the total byte count for the sub-requests payload.

Source

pub fn clear_all(&mut self)

Clears all sub-requests.

Trait Implementations§

Source§

impl Clone for SubRequest

Source§

fn clone(&self) -> SubRequest

Returns a duplicate 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 Debug for SubRequest

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for SubRequest

Source§

fn default() -> SubRequest

Returns the “default value” for a type. Read more
Source§

impl PduDataBytes for SubRequest

Source§

fn to_sub_req_pdu_bytes(&self) -> Result<Vec<u8, MAX_PDU_DATA_LEN>, MbusError>

Converts the sub-request parameters into a byte vector for the PDU.

Auto Trait Implementations§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.