pub struct ExceptionResponse {
pub function_code: FunctionCode,
pub exception_code: ExceptionCode,
}Expand description
Modbus exception response.
Sent by a server when a request cannot be processed. The function code byte on the wire has bit 7 set (0x80 flag).
Fields§
§function_code: FunctionCodeThe original function code (without the 0x80 flag).
exception_code: ExceptionCodeThe exception code indicating the error condition.
Implementations§
Source§impl ExceptionResponse
impl ExceptionResponse
Sourcepub fn decode(fc_byte: u8, data: &[u8]) -> Result<Self, DecodeError>
pub fn decode(fc_byte: u8, data: &[u8]) -> Result<Self, DecodeError>
Decode from the raw function code byte and remaining data.
The fc_byte parameter is the raw byte from the wire WITH the 0x80
exception flag still set. The flag is stripped internally using
FunctionCode::from_exception_raw.
§Errors
Returns DecodeError::Truncated if data is too short.
Returns DecodeError::LengthMismatch if data has extra bytes.
Returns DecodeError::UnknownFunctionCode if the function code is not
recognized.
Returns DecodeError::UnknownExceptionCode if the exception code is
not recognized.
Trait Implementations§
Source§impl Clone for ExceptionResponse
impl Clone for ExceptionResponse
Source§fn clone(&self) -> ExceptionResponse
fn clone(&self) -> ExceptionResponse
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ExceptionResponse
Source§impl Debug for ExceptionResponse
impl Debug for ExceptionResponse
Source§impl Encode for ExceptionResponse
impl Encode for ExceptionResponse
Source§fn encode_into(&self, buf: &mut [u8]) -> Result<usize, EncodeError>
fn encode_into(&self, buf: &mut [u8]) -> Result<usize, EncodeError>
Write the full PDU (function code + data) into
buf. Read moreSource§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Total encoded length in bytes (including the function code byte).
Auto Trait Implementations§
impl Freeze for ExceptionResponse
impl RefUnwindSafe for ExceptionResponse
impl Send for ExceptionResponse
impl Sync for ExceptionResponse
impl Unpin for ExceptionResponse
impl UnsafeUnpin for ExceptionResponse
impl UnwindSafe for ExceptionResponse
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