pub struct TetherAgentBuilder { /* private fields */ }Expand description
Typically, you will use this to construct a well-configured TetherAgent with a combination of sensible defaults and custom overrides.
Make a new instance of TetherAgentBuilder with TetherAgentBuilder::new(), chain whatever
overrides you might need, and finally call build() to get the actual TetherAgent instance.
Implementations§
Source§impl TetherAgentBuilder
impl TetherAgentBuilder
Sourcepub fn new(role: &str) -> Self
pub fn new(role: &str) -> Self
Initialise Tether Options struct with default options; call other methods to customise.
Call build() to get the actual TetherAgent instance (and connect automatically, by default)
Sourcepub fn id(self, id: Option<&str>) -> Self
pub fn id(self, id: Option<&str>) -> Self
Optionally sets the Tether ID, as used in auto-generating topics such as myRole/myID/myChannel not the MQTT Client ID.
Provide Some(value) to override or None to use the default any (when publishing) or + when subscribing.
Sourcepub fn protocol(self, protocol: Option<&str>) -> Self
pub fn protocol(self, protocol: Option<&str>) -> Self
Provide Some(value) to override or None to use default
Sourcepub fn mqtt_client_id(self, client_id: Option<&str>) -> Self
pub fn mqtt_client_id(self, client_id: Option<&str>) -> Self
Optionally set the MQTT Client ID used when connecting to the MQTT broker. This is not the same as the Tether ID used for auto-generating topics.
By default we use a UUID for this value, in order to avoid hard-to-debug issues where Tether Agent instances share the same Client ID and therefore events/messages are not handled properly by all instances.
Sourcepub fn host(self, host: Option<&str>) -> Self
pub fn host(self, host: Option<&str>) -> Self
Provide Some(value) to override or None to use default
pub fn port(self, port: Option<u16>) -> Self
Sourcepub fn username(self, username: Option<&str>) -> Self
pub fn username(self, username: Option<&str>) -> Self
Provide Some(value) to override or None to use default
Sourcepub fn password(self, password: Option<&str>) -> Self
pub fn password(self, password: Option<&str>) -> Self
Provide Some(value) to override or None to use default
Sourcepub fn base_path(self, base_path: Option<&str>) -> Self
pub fn base_path(self, base_path: Option<&str>) -> Self
Provide Some(value) to override or None to use default
Sourcepub fn auto_connect(self, should_auto_connect: bool) -> Self
pub fn auto_connect(self, should_auto_connect: bool) -> Self
Specify explicitly whether to attempt auto-connection on build;
if set to false you will need to connect the TetherAgent (and therefore
its underlying MQTT client) yourself after creating the instance.
Sourcepub fn build(self) -> Result<TetherAgent>
pub fn build(self) -> Result<TetherAgent>
Using a combination of sensible defaults and any overrides you might have provided using other functions called on TetherAgentOptions, this function returns a well-configured TetherAgent instance.
Unless you set .auto_connect(false), the TetherAgent will attempt to
connect to the MQTT broker automatically upon creation.
Trait Implementations§
Source§impl Clone for TetherAgentBuilder
impl Clone for TetherAgentBuilder
Source§fn clone(&self) -> TetherAgentBuilder
fn clone(&self) -> TetherAgentBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more