pub struct Message<TCustom> {
pub data: MsgData<TCustom>,
pub key: String,
pub ts: Timestamp,
pub trace: MsgTrace,
/* private fields */
}
Expand description
Сообщение
Fields§
§data: MsgData<TCustom>
Данные
key: String
Ключ
ts: Timestamp
Метка времени
trace: MsgTrace
Путь, по котором передавалось сообщение
Implementations§
Source§impl<TCustom> Message<TCustom>where
TCustom: MsgDataBound,
impl<TCustom> Message<TCustom>where
TCustom: MsgDataBound,
Sourcepub fn new_custom(custom_data: TCustom) -> Self
pub fn new_custom(custom_data: TCustom) -> Self
Создать новое сообщение типа MsgData::Custom
Sourcepub fn get_custom_data(&self) -> Option<TCustom>
pub fn get_custom_data(&self) -> Option<TCustom>
Возвращает данные сообщения, если тип сообщения MsgData::Custom
Sourcepub fn add_trace_item(&mut self, id: &Uuid)
pub fn add_trace_item(&mut self, id: &Uuid)
Добавить запись пути
Sourcepub fn contains_trace_item(&self, id: &Uuid) -> bool
pub fn contains_trace_item(&self, id: &Uuid) -> bool
Проверяем, что в трейсе сообщения присутсвует компонент с заданным id.
Полезно для предотварщения зацикливания сообщений, чтобы данный компонент не обрабатывал сообщения, которые он же и сгенерировал
Sourcepub fn update_time_to_live(&mut self, time_step: Duration)
pub fn update_time_to_live(&mut self, time_step: Duration)
Обновить время жизни сообщения
Sourcepub fn service_origin(&self) -> String
pub fn service_origin(&self) -> String
Возращает название сервиса, в котором было создано данное сообщение. Паникует, если название сервиса еще не установлено
Sourcepub fn set_service_origin(&mut self, service: &str)
pub fn set_service_origin(&mut self, service: &str)
Устанавливает название сервиса, в котором было создано данное сообщение. Если название уже установлено, то пропускаем
Sourcepub fn is_route_enabled(
&self,
src: &TCustom::TService,
dst: &TCustom::TService,
) -> bool
pub fn is_route_enabled( &self, src: &TCustom::TService, dst: &TCustom::TService, ) -> bool
Разрешен ли марштур данного сообщения
Source§impl<TData> Message<TData>where
TData: DeserializeOwned + Serialize,
impl<TData> Message<TData>where
TData: DeserializeOwned + Serialize,
Sourcepub fn serialize_json_pretty(&self) -> Result<String, Error>
pub fn serialize_json_pretty(&self) -> Result<String, Error>
Сериализация сообщений в json
Sourcepub fn serialize_data(&self) -> Result<String, Error>
pub fn serialize_data(&self) -> Result<String, Error>
Сериализация полей данных сообщений в json
Sourcepub fn deserialize(text: &str) -> Result<Self, Error>
pub fn deserialize(text: &str) -> Result<Self, Error>
Десериализация одного сообщения из json
Trait Implementations§
Source§impl<'de, TCustom> Deserialize<'de> for Message<TCustom>where
TCustom: Deserialize<'de>,
impl<'de, TCustom> Deserialize<'de> for Message<TCustom>where
TCustom: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl<TCustom> StructuralPartialEq for Message<TCustom>
Auto Trait Implementations§
impl<TCustom> Freeze for Message<TCustom>where
TCustom: Freeze,
impl<TCustom> RefUnwindSafe for Message<TCustom>where
TCustom: RefUnwindSafe,
impl<TCustom> Send for Message<TCustom>where
TCustom: Send,
impl<TCustom> Sync for Message<TCustom>where
TCustom: Sync,
impl<TCustom> Unpin for Message<TCustom>where
TCustom: Unpin,
impl<TCustom> UnwindSafe for Message<TCustom>where
TCustom: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Erasable for T
impl<T> Erasable for T
§impl<T> FromBase64 for Twhere
T: for<'de> Deserialize<'de>,
impl<T> FromBase64 for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more