ModbusBuffer

Struct ModbusBuffer 

Source
pub struct ModbusBuffer<const CAPACITY: usize> { /* private fields */ }

Implementations§

Source§

impl<const CAPACITY: usize> ModbusBuffer<CAPACITY>

Source

pub fn new() -> Self

Creates a new ModbusBuffer with specified constants.

Source

pub fn min_frame_len(self, min_frame_len: usize) -> Self

Sets the minimum frame length required to detect a Modbus frame, excluding CRC.

Source

pub fn max_frame_len(self, max_frame_len: usize) -> Self

Sets the maximum frame length that can be detected, excluding CRC.

Source

pub fn overwrite(self, overwrite: bool) -> Self

Configures whether to overwrite old data if the buffer is full or to panic.

Source

pub fn push(&mut self, item: u8)

Adds an item to the buffer, handling overflow based on the overwrite flag.

Source

pub fn pop(&mut self) -> Option<u8>

Removes and returns the oldest element from the buffer if available.

Source

pub fn len(&self) -> usize

Returns the current number of elements in the buffer.

Source

pub fn is_empty(&self) -> bool

Returns true if the buffer is empty.

Source

pub fn is_full(&self) -> bool

Returns true if the buffer is full.

Source

pub fn try_decode_frame(&mut self, buffer: &mut [u8; CAPACITY]) -> Option<usize>

Attempts to decode a Modbus frame from the internal buffer and copies it into the provided buffer if successful.

Trait Implementations§

Source§

impl<const CAPACITY: usize> Debug for ModbusBuffer<CAPACITY>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<const CAPACITY: usize> Freeze for ModbusBuffer<CAPACITY>

§

impl<const CAPACITY: usize> RefUnwindSafe for ModbusBuffer<CAPACITY>

§

impl<const CAPACITY: usize> Send for ModbusBuffer<CAPACITY>

§

impl<const CAPACITY: usize> Sync for ModbusBuffer<CAPACITY>

§

impl<const CAPACITY: usize> Unpin for ModbusBuffer<CAPACITY>

§

impl<const CAPACITY: usize> UnwindSafe for ModbusBuffer<CAPACITY>

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> 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.