Struct Conf

Source
pub struct Conf { /* private fields */ }
Expand description

Specify server behavior.

Many methods take a Vec of values, where the Nth mod len() value is used for the Nth connection. For example, .max_pkt(vec![None,Some(3)]) applies the limit to every second connection.

Implementations§

Source§

impl Conf

Source

pub fn new() -> Self

Initialize a default config

Source

pub fn ports(self, ports: RangeInclusive<u16>) -> Self

Range of ports to try to listen on, stopping at the first successful one) (defaults to 1883..=2000)

Source

pub fn dump_files(self, vs: Vec<impl Into<String>>) -> Self

Dump packets to files.

The filename can contain a {c} placeholder that will be replaced by the connection number. The dump format is json-serialized DumpMeta struct.

Source

pub fn dump_prefix(self, s: impl Into<String>) -> Self

Source

pub fn dump_decode(self, s: impl Into<Option<String>>) -> Self

Decode command for publish payload.

The argument should be a command that reads raw payload from stdin, and writes the corresponding utf8/json to stdout. If decoding fails, it should output diagnostics to stderr and exit with a non-zero value.

Source

pub fn ack_timeouts( self, mqtt3: impl Into<OptMsDuration>, mqtt5: impl Into<OptMsDuration>, ) -> Self

Resend packet during connection if ack takes longer than this (defaults to 5s).

This only concerns resending during a live connection: resending at connection start (if session was restored) always happens immediately.

The second value is for MQTT5 clients. MQTT5 forbids resending during connection, only set an MQTT5 value for testing purposes. MQTT3 doesn’t specify a behaviour, but many client/servers do resend non-acked packets during connection.

Source

pub fn ack_delay(self, d: impl Into<OptMsDuration>) -> Self

Delay before sending publish and subscribe acks.

Source

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

Be stricter about optional MQTT behaviours.

  • MQTT-3.1.3-5: Reject client_ids longer than 23 chars or not matching [0-9a-zA-Z].
  • MQTT-3.1.3-6: Reject empty client_ids.
Source

pub fn idprefix(self, s: impl Into<String>) -> Self

Reject clients whose client_id does not start with this prefix.

Source

pub fn userpass(self, s: impl Into<Option<String>>) -> Self

Reject clients who didn’t suppliy this username:password

Note that MQTT allows passwords to be binary but we only accept UTF-8.

Source

pub fn max_connect(self, c: impl Into<Option<usize>>) -> Self

Only accept up to N connections, and stop the server afterwards.

Source

pub fn max_pkt(self, vou: Vec<impl Into<Option<usize>>>) -> Self

Disconnect the Nth client after receiving that many packets.

This just closes the TCP stream, without sending an mqtt disconnect packet.

Source

pub fn max_pkt_delay(self, d: impl Into<OptMsDuration>) -> Self

Delay before max-pkt disconnection.

Useful if you want to receive the server response before disconnection.

Source

pub fn max_time(self, vod: Vec<impl Into<OptMsDuration>>) -> Self

Disconnect the Nth client after a certain time.

This just closes the TCP stream, without sending an mqtt disconnect packet.

Source

pub fn sess_expire(self, vod: Vec<impl Into<OptMsDuration>>) -> Self

How long is the Nth session retained after disconnection.

If None, use client-specified behaviour (clean_session in MQTT3, session expiry in MQTT5).

Trait Implementations§

Source§

impl Clone for Conf

Source§

fn clone(&self) -> Conf

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 Debug for Conf

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Conf

§

impl RefUnwindSafe for Conf

§

impl Send for Conf

§

impl Sync for Conf

§

impl Unpin for Conf

§

impl UnwindSafe for Conf

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V