pub struct Config<TMsg>where
TMsg: MsgDataBound,{
pub client_id: String,
pub host: String,
pub port: u16,
pub fn_input: ConfigFnInput<TMsg>,
pub fn_output: ConfigFnOutput<TMsg>,
}
Expand description
Конфигурация cmp_mqtt_client
Fields§
§client_id: String
Идентификатор клиента MQTT
host: String
Адрес брокера
Примеры:
localhost
port: u16
Порт брокера.
По-умолчанию - 1883
fn_input: ConfigFnInput<TMsg>
Функция преобразования входящих сообщений в данные для публикации в брокере
Примеры
- ничего не отправлять в брокер
fn_input: |_| Ok(None)
- сериализация данных без фильтрации
fn_input: |msg| Ok(Some(msg.serialize()?.into_bytes()))
fn_output: ConfigFnOutput<TMsg>
Функция преобразования данных, полученных из брокера, в исходящие сообщения
Примеры
- ничего не получать из брокера
fn_output: |_| Ok(None)
- десериализация данных без фильтрации
fn_output: |payload: &[u8]| {
let payload = String::from_utf8_lossy(&payload);
let msg = Message::deserialize(&payload)?;
Ok(Some(msg))
}
Trait Implementations§
Source§impl<TMsg, TService> IComponentProcess<Config<TMsg>, TMsg, TService> for Component<Config<TMsg>, TMsg, TService>where
TMsg: MsgDataBound + 'static,
TService: ServiceBound + 'static,
impl<TMsg, TService> IComponentProcess<Config<TMsg>, TMsg, TService> for Component<Config<TMsg>, TMsg, TService>where
TMsg: MsgDataBound + 'static,
TService: ServiceBound + 'static,
Auto Trait Implementations§
impl<TMsg> Freeze for Config<TMsg>
impl<TMsg> RefUnwindSafe for Config<TMsg>
impl<TMsg> Send for Config<TMsg>
impl<TMsg> Sync for Config<TMsg>
impl<TMsg> Unpin for Config<TMsg>
impl<TMsg> UnwindSafe for Config<TMsg>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more