blob: bd46b51a2dfe1434add1d06aa2c3f78f8dd5987b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
pub mod connect;
mod receive;
pub mod send;
mod state;
use std::sync::Arc;
use futures::lock::Mutex;
use self::send::Acknowledge;
use self::send::Callbacks;
use self::send::ClientHandlers;
use self::state::ConnectState;
use self::state::SessionState;
struct InnerClient {
connection_state: Option<ConnectState>,
session_state: Option<SessionState>,
default_handlers: ClientHandlers,
outstanding_callbacks: Callbacks,
}
pub struct MqttClient {
inner: Arc<Mutex<InnerClient>>,
}
impl MqttClient {
pub fn new_with_default_handlers() -> MqttClient {
MqttClient {
inner: Arc::new(Mutex::new(InnerClient {
connection_state: None,
session_state: None,
default_handlers: ClientHandlers::default(),
outstanding_callbacks: Callbacks::new(),
})),
}
}
}
#[cfg(test)]
mod tests {
use crate::client::ClientHandlers;
use crate::client::MqttClient;
static_assertions::assert_impl_all!(MqttClient: Send, Sync);
static_assertions::assert_impl_all!(ClientHandlers: Send);
}
|