pub enum Request<'a> {
    ReadCoils(Address, Quantity),
    ReadDiscreteInputs(Address, Quantity),
    WriteSingleCoil(Address, bool),
    WriteMultipleCoils(Address, Cow<'a, [bool]>),
    ReadInputRegisters(Address, Quantity),
    ReadHoldingRegisters(Address, Quantity),
    WriteSingleRegister(Address, u16),
    WriteMultipleRegisters(Address, Cow<'a, [u16]>),
    MaskWriteRegister(Address, u16, u16),
    ReadWriteMultipleRegisters(Address, Quantity, Address, Cow<'a, [u16]>),
    Custom(u8, Cow<'a, [u8]>),
    Disconnect,
}
Expand description

A request represents a message from the client (master) to the server (slave).

Variants§

§

ReadCoils(Address, Quantity)

A request to read multiple coils. The first parameter is the address of the first coil to read. The second parameter is the number of coils to read.

§

ReadDiscreteInputs(Address, Quantity)

A request to read multiple discrete inputs The first parameter is the address of the first discrete input to read. The second parameter is the number of discrete inputs to read.

§

WriteSingleCoil(Address, bool)

A request to write a single coil. The first parameter is the address of the coil. The second parameter is the value to write to the coil.

§

WriteMultipleCoils(Address, Cow<'a, [bool]>)

A request to write multiple coils. The first parameter is the address of the first coil to write. The second parameter is the vector of values to write to the coils.

§

ReadInputRegisters(Address, Quantity)

A request to read multiple input registers. The first parameter is the address of the first input register to read. The second parameter is the number of input registers to read.

§

ReadHoldingRegisters(Address, Quantity)

A request to read multiple holding registers. The first parameter is the address of the first holding register to read. The second parameter is the number of holding registers to read.

§

WriteSingleRegister(Address, u16)

A request to write a single register. The first parameter is the address of the register to read. The second parameter is the value to write to the register.

§

WriteMultipleRegisters(Address, Cow<'a, [u16]>)

A request to write to multiple registers. The first parameter is the address of the first register to write. The second parameter is the vector of values to write to the registers.

§

MaskWriteRegister(Address, u16, u16)

A request to set or clear individual bits of a holding register. The first parameter is the address of the holding register. The second parameter is the AND mask. The third parameter is the OR mask.

§

ReadWriteMultipleRegisters(Address, Quantity, Address, Cow<'a, [u16]>)

A request to simultaneously read multiple registers and write multiple registers. The first parameter is the address of the first register to read. The second parameter is the number of registers to read. The third parameter is the address of the first register to write. The fourth parameter is the vector of values to write to the registers.

§

Custom(u8, Cow<'a, [u8]>)

A raw Modbus request. The first parameter is the Modbus function code. The second parameter is the raw bytes of the request.

§

Disconnect

A poison pill for stopping the client service and to release the underlying transport, e.g. for disconnecting from an exclusively used serial port.

This is an ugly workaround, because tokio-proto does not provide other means to gracefully shut down the ClientService. Otherwise the bound transport is never freed as long as the executor is active, even when dropping the Modbus client context.

Implementations§

source§

impl<'a> Request<'a>

source

pub fn into_owned(self) -> Request<'static>

Converts the request into an owned instance with 'static' lifetime.

source

pub const fn function_code(&self) -> FunctionCode

Get the FunctionCode of the Request.

Trait Implementations§

source§

impl<'a> Clone for Request<'a>

source§

fn clone(&self) -> Request<'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 Request<'a>

source§

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

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

impl<'a> PartialEq for Request<'a>

source§

fn eq(&self, other: &Request<'a>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<Bytes> for Request<'static>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(bytes: Bytes) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<Request<'a>> for Bytes

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(req: Request<'a>) -> Result<Bytes, Self::Error>

Performs the conversion.
source§

impl<'a> Eq for Request<'a>

source§

impl<'a> StructuralPartialEq for Request<'a>

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Request<'a>

§

impl<'a> Send for Request<'a>

§

impl<'a> Sync for Request<'a>

§

impl<'a> Unpin for Request<'a>

§

impl<'a> UnwindSafe for Request<'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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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,

§

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

§

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

§

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more