pub fn new(
        broker: IpAddr,
        client_id: &str,
        network_stack: TcpStack,
        clock: Clock,
    ) -> Result<Self, Error<TcpStack::Error>> {
        let session_state = SessionState::new(
            broker,
            String::from_str(client_id).or(Err(Error::ProvidedClientIdTooLong))?,
        );

        let minimq = Minimq {
            client: MqttClient {
                network: InterfaceHolder::new(network_stack),
                clock,
                session_state,
                connection_state: StateMachine::new(Context),
            },
            packet_reader: PacketReader::new(),
        };

        Ok(minimq)
    }
/// Construct a new MQTT interface.
///
/// # Args
/// * `broker` - The IP address of the broker to connect to.
/// * `client_id` The client ID to use for communicating with the broker. If empty, rely on the
///   broker to automatically assign a client ID.
/// * `network_stack` - The network stack to use for communication.
/// * `clock` - The clock to use for managing MQTT state timing.
///
/// # Returns
/// A `Minimq` object that can be used for publishing messages, subscribing to topics, and
/// managing the MQTT state.
Construct a new MQTT interface.
Construct a new MQTT interface .
pub fn new(
        broker: IpAddr,
        client_id: &str,
        network_stack: TcpStack,
        clock: Clock,
    ) -> Result<Self, Error<TcpStack::Error>> {
        let session_state = SessionState::new(
            broker,
            String::from_str(client_id).or(Err(Error::ProvidedClientIdTooLong))?,
        );
        let minimq = Minimq {
            client: MqttClient {
                network: InterfaceHolder::new(network_stack),
                clock,
                session_state,
                connection_state: StateMachine::new(Context),
            },
            packet_reader: PacketReader::new(),
        };
        Ok(minimq)
    }
pub fn new ( broker : IpAddr , client_id : & str , network_stack : TcpStack , clock : Clock , ) -> Result < Self , Error < TcpStack :: Error > > { let session_state = SessionState :: new ( broker , String :: from_str ( client_id ) . or ( Err ( Error :: ProvidedClientIdTooLong ) ) ? , ) ; let minimq = Minimq { client : MqttClient { network : InterfaceHolder :: new ( network_stack ) , clock , session_state , connection_state : StateMachine :: new ( Context ) , } , packet_reader : PacketReader :: new ( ) , } ; Ok ( minimq ) }
Construct a new MQTT interface.
Construct a new MQTT interface .
A `Minimq` object that can be used for publishing messages, subscribing to topics, and
managing the MQTT state.
A ` Minimq ` object that can be used for publishing messages subscribing to topics and managing the MQTT state .
broker
IpAddr
client_id
&str
network_stack
TcpStack
clock
Clock
args
`broker` - The IP address of the broker to connect to.
`client_id` The client ID to use for communicating with the broker. If empty, rely on the
broker to automatically assign a client ID.
`network_stack` - The network stack to use for communication.
`clock` - The clock to use for managing MQTT state timing.
` broker ` - The IP address of the broker to connect to . ` client_id ` The client ID to use for communicating with the broker . If empty rely on the broker to automatically assign a client ID . ` network_stack ` - The network stack to use for communication . ` clock ` - The clock to use for managing MQTT state timing .