pub struct Frame<T> { /* private fields */ }Expand description
A complete Modbus frame.
Implementations§
Source§impl<T> Frame<T>
impl<T> Frame<T>
Sourcepub fn new(unit_id: u8, pdu: T) -> Selfwhere
T: Pdu,
pub fn new(unit_id: u8, pdu: T) -> Selfwhere
T: Pdu,
Creates a new frame with the given unit ID and PDU and calculates the CRC.
Sourcepub const fn builder(unit_id: u8) -> FrameBuilder<T>where
T: Pdu,
pub const fn builder(unit_id: u8) -> FrameBuilder<T>where
T: Pdu,
Creates a new FrameBuilder.
Sourcepub fn validate_crc(&self) -> Result<(), CrcError>
pub fn validate_crc(&self) -> Result<(), CrcError>
Validates the CRC of the frame. Self::into_data will also validate
the CRC, so in most cases you should not need to call this method
directly.
Trait Implementations§
Source§impl<T> FromBytes for Frame<T>
impl<T> FromBytes for Frame<T>
Source§impl<T> IntoBytes for Frame<T>
impl<T> IntoBytes for Frame<T>
Source§fn as_mut_bytes(&mut self) -> &mut [u8] ⓘwhere
Self: FromBytes,
fn as_mut_bytes(&mut self) -> &mut [u8] ⓘwhere
Self: FromBytes,
Gets the bytes of this value mutably. Read more
Source§fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>where
Self: Immutable,
fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>where
Self: Immutable,
Source§impl<T> TryFromBytes for Frame<T>
impl<T> TryFromBytes for Frame<T>
Source§fn try_read_from_bytes(
source: &[u8],
) -> Result<Self, ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_bytes(
source: &[u8],
) -> Result<Self, ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
Source§fn try_read_from_prefix(
source: &[u8],
) -> Result<(Self, &[u8]), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_prefix(
source: &[u8],
) -> Result<(Self, &[u8]), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
Source§fn try_read_from_suffix(
source: &[u8],
) -> Result<(&[u8], Self), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_suffix(
source: &[u8],
) -> Result<(&[u8], Self), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
impl<T: Copy> Copy for Frame<T>
impl<T: Eq> Eq for Frame<T>
impl<T> Immutable for Frame<T>
impl<T> StructuralPartialEq for Frame<T>
impl<T> Unaligned for Frame<T>
Auto Trait Implementations§
impl<T> Freeze for Frame<T>where
T: Freeze,
impl<T> RefUnwindSafe for Frame<T>where
T: RefUnwindSafe,
impl<T> Send for Frame<T>where
T: Send,
impl<T> Sync for Frame<T>where
T: Sync,
impl<T> Unpin for Frame<T>where
T: Unpin,
impl<T> UnsafeUnpin for Frame<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Frame<T>where
T: UnwindSafe,
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