Skip to main content

ClientBuilder

Struct ClientBuilder 

Source
pub struct ClientBuilder<S, TX, D = NoDelay> { /* private fields */ }
Expand description

Builder for Client. Obtain via Client::builder().

Uses the same typestate pattern as BridgeBuilder. S and TX start as () until .rtu() is called. D starts as NoDelay and can be upgraded with .delay().

Implementations§

Source§

impl ClientBuilder<(), (), NoDelay>

Source

pub fn new() -> Self

Creates a new ClientBuilder with no serial port configured.

Prefer Client::builder() over calling this directly.

Source§

impl<D> ClientBuilder<(), (), D>

Source

pub fn rtu<S, TX>(self, serial: S, tx_en: TX) -> ClientBuilder<S, TX, D>

Supplies the serial port and RS-485 TX-enable pin.

§Examples
let client = Client::builder()
    .rtu(uart, tx_en_pin)
    .build();
Source

pub fn rtu_no_pin<S>(self, serial: S) -> ClientBuilder<S, NoPin, D>

Supplies the serial port without a TX-enable pin.

Use this when the RS-485 transceiver handles direction control automatically.

§Examples
let client = Client::builder()
    .rtu_no_pin(uart)
    .build();
Source§

impl<S, TX, D> ClientBuilder<S, TX, D>

Source

pub fn rtu_timeout(self, ms: u32) -> Self

Sets the RTU I/O timeout in milliseconds.

Applied while waiting for an incoming RTU request from the serial master. Requires a delay provider — call .delay() as well.

Source

pub fn tcp_timeout(self, ms: u32) -> Self

Sets the TCP I/O timeout in milliseconds.

Applied while waiting for the upstream TCP server response. Requires a delay provider — call .delay() as well.

Source

pub fn build(self) -> Client<S, TX, D>

Builds and returns the configured Client.

§Examples
let mut client = Client::builder()
    .rtu(uart, tx_en)
    .build();
Source§

impl<S, TX> ClientBuilder<S, TX, NoDelay>

Source

pub fn delay<D2>(self, delay: D2) -> ClientBuilder<S, TX, D2>

Supplies a delay provider and upgrades D from NoDelay.

Must be called before .build() when using .rtu_timeout() or .tcp_timeout().

§Examples
let client = Client::builder()
    .rtu(uart, pin)
    .rtu_timeout(500)
    .delay(my_timer)
    .build();

Trait Implementations§

Source§

impl Default for ClientBuilder<(), (), NoDelay>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<S, TX, D> Freeze for ClientBuilder<S, TX, D>
where S: Freeze, TX: Freeze, D: Freeze,

§

impl<S, TX, D> RefUnwindSafe for ClientBuilder<S, TX, D>

§

impl<S, TX, D> Send for ClientBuilder<S, TX, D>
where S: Send, TX: Send, D: Send,

§

impl<S, TX, D> Sync for ClientBuilder<S, TX, D>
where S: Sync, TX: Sync, D: Sync,

§

impl<S, TX, D> Unpin for ClientBuilder<S, TX, D>
where S: Unpin, TX: Unpin, D: Unpin,

§

impl<S, TX, D> UnsafeUnpin for ClientBuilder<S, TX, D>

§

impl<S, TX, D> UnwindSafe for ClientBuilder<S, TX, D>
where S: UnwindSafe, TX: UnwindSafe, D: UnwindSafe,

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.