#[repr(C)]pub struct UAttributes { /* private fields */ }Expand description
Message metadata: addressing, identity, type, and delivery options for one UMessage.
Implementations§
Source§impl UAttributes
impl UAttributes
Sourcepub fn type_(&self) -> UMessageType
pub fn type_(&self) -> UMessageType
Gets the type of message these are the attributes of.
§Example
use up_rust::{UMessageBuilder, UMessageType, UUri};
let topic = UUri::try_from("//my-vehicle/D45/23/A001")?;
let msg = UMessageBuilder::publish(topic).build()?;
let attribs = msg.attributes();
assert_eq!(attribs.type_(), UMessageType::Publish);Sourcepub fn id(&self) -> &UUID
pub fn id(&self) -> &UUID
Gets the identifier of the message these attributes belong to.
§Example
use up_rust::{UMessageBuilder, UMessageType, UUri, UUID};
let topic = UUri::try_from("//my-vehicle/D45/23/A001")?;
let msg_id = UUID::build();
let msg = UMessageBuilder::publish(topic).with_message_id(msg_id.clone()).build()?;
let attribs = msg.attributes();
assert_eq!(attribs.id(), &msg_id);Sourcepub fn source(&self) -> &UUri
pub fn source(&self) -> &UUri
Gets the source address of the message these attributes belong to.
§Example
use up_rust::{UMessageBuilder, UMessageType, UUri};
let topic = UUri::try_from("//my-vehicle/D45/23/A001")?;
let msg = UMessageBuilder::publish(topic.clone()).build()?;
let attribs = msg.attributes();
assert_eq!(attribs.source(), &topic);Sourcepub fn sink(&self) -> Option<&UUri>
pub fn sink(&self) -> Option<&UUri>
Gets the sink address of the message these attributes belong to.
§Example
use up_rust::{UMessageBuilder, UMessageType, UUri};
let origin = UUri::try_from("//my-vehicle/D45/23/A001")?;
let dest = UUri::try_from("//other-vehicle/D10/3/0")?;
let msg = UMessageBuilder::notification(origin, dest.clone()).build()?;
let attribs = msg.attributes();
assert_eq!(attribs.sink(), Some(&dest));Sourcepub fn sink_unchecked(&self) -> &UUri
pub fn sink_unchecked(&self) -> &UUri
Gets the sink address of the message these attributes belong to.
§Panics
if the property has no value.
§Example
use up_rust::{UMessageBuilder, UMessageType, UUri};
let origin = UUri::try_from("//my-vehicle/D45/23/A001")?;
let dest = UUri::try_from("//other-vehicle/D10/3/0")?;
let msg = UMessageBuilder::notification(origin, dest.clone()).build()?;
let attribs = msg.attributes();
assert_eq!(attribs.sink_unchecked(), &dest);Sourcepub fn priority(&self) -> Option<UPriority>
pub fn priority(&self) -> Option<UPriority>
Gets the priority of the message these attributes belong to.
§Example
use up_rust::{UMessageBuilder, UMessageType, UPriority, UUri};
let topic = UUri::try_from("//my-vehicle/D45/23/A001")?;
let msg = UMessageBuilder::publish(topic).with_priority(UPriority::CS3).build()?;
let attribs = msg.attributes();
assert_eq!(attribs.priority(), Some(UPriority::CS3));Sourcepub fn priority_unchecked(&self) -> UPriority
pub fn priority_unchecked(&self) -> UPriority
Gets the priority of the message these attributes belong to.
§Panics
if the property has no value.
§Example
use up_rust::{UMessageBuilder, UMessageType, UPriority, UUri};
let topic = UUri::try_from("//my-vehicle/D45/23/A001")?;
let msg = UMessageBuilder::publish(topic).with_priority(UPriority::CS3).build()?;
let attribs = msg.attributes();
assert_eq!(attribs.priority_unchecked(), UPriority::CS3);Sourcepub fn commstatus(&self) -> Option<UCode>
pub fn commstatus(&self) -> Option<UCode>
Gets the commstatus of the message these attributes belong to.
§Example
use up_rust::{UCode, UMessageBuilder, UMessageType, UUID, UUri};
let invoked_method = UUri::try_from("//my-vehicle/D45/2/101")?;
let reply_to = UUri::try_from("//other-vehicle/D10/3/0")?;
let msg = UMessageBuilder::response(reply_to, UUID::build(), invoked_method)
.with_comm_status(UCode::Ok)
.build()?;
let attribs = msg.attributes();
assert_eq!(attribs.commstatus(), Some(UCode::Ok));Sourcepub fn commstatus_unchecked(&self) -> UCode
pub fn commstatus_unchecked(&self) -> UCode
Gets the commstatus of the message these attributes belong to.
§Panics
if the property has no value.
§Example
use up_rust::{UCode, UMessageBuilder, UMessageType, UUID, UUri};
let invoked_method = UUri::try_from("//my-vehicle/D45/2/101")?;
let reply_to = UUri::try_from("//other-vehicle/D10/3/0")?;
let msg = UMessageBuilder::response(reply_to, UUID::build(), invoked_method)
.with_comm_status(UCode::Internal)
.build()?;
let attribs = msg.attributes();
assert_eq!(attribs.commstatus_unchecked(), UCode::Internal);Sourcepub fn ttl(&self) -> Option<u32>
pub fn ttl(&self) -> Option<u32>
Gets the time-to-live of the message these attributes belong to.
§Returns
the time-to-live in milliseconds.
§Example
use up_rust::{UMessageBuilder, UUri};
let invoked_method = UUri::try_from("//my-vehicle/D45/2/101")?;
let reply_to = UUri::try_from("//other-vehicle/D10/3/0")?;
let msg = UMessageBuilder::request(invoked_method, reply_to, 5000)
.build()?;
let attribs = msg.attributes();
assert_eq!(attribs.ttl(), Some(5000));Sourcepub fn ttl_unchecked(&self) -> u32
pub fn ttl_unchecked(&self) -> u32
Gets the time-to-live of the message these attributes belong to.
§Returns
the time-to-live in milliseconds.
§Panics
if the property has no value.
§Example
use up_rust::{UMessageBuilder, UUri};
let invoked_method = UUri::try_from("//my-vehicle/D45/2/101")?;
let reply_to = UUri::try_from("//other-vehicle/D10/3/0")?;
let msg = UMessageBuilder::request(invoked_method, reply_to, 5000)
.build()?;
let attribs = msg.attributes();
assert_eq!(attribs.ttl_unchecked(), 5000);Sourcepub fn permission_level(&self) -> Option<u32>
pub fn permission_level(&self) -> Option<u32>
Gets the permission level of the message these attributes belong to.
§Example
use up_rust::{UMessageBuilder, UUri};
let invoked_method = UUri::try_from("//my-vehicle/D45/2/101")?;
let reply_to = UUri::try_from("//other-vehicle/D10/3/0")?;
let msg = UMessageBuilder::request(invoked_method, reply_to, 5000)
.with_permission_level(3)
.build()?;
let attribs = msg.attributes();
assert_eq!(attribs.permission_level(), Some(3));Sourcepub fn token(&self) -> Option<&str>
pub fn token(&self) -> Option<&str>
Gets the token of the message these attributes belong to.
§Example
use up_rust::{UMessageBuilder, UUri};
let token = "my_token";
let invoked_method = UUri::try_from("//my-vehicle/D45/2/101")?;
let reply_to = UUri::try_from("//other-vehicle/D10/3/0")?;
let msg = UMessageBuilder::request(invoked_method, reply_to, 5000)
.with_token(token)
.build()?;
let attribs = msg.attributes();
assert_eq!(attribs.token(), Some(token));Sourcepub fn traceparent(&self) -> Option<&str>
pub fn traceparent(&self) -> Option<&str>
Gets the traceparent of the message these attributes belong to.
§Example
use up_rust::{UMessageBuilder, UUri};
let traceparent = "my_traceparent";
let invoked_method = UUri::try_from("//my-vehicle/D45/2/101")?;
let reply_to = UUri::try_from("//other-vehicle/D10/3/0")?;
let msg = UMessageBuilder::request(invoked_method, reply_to, 5000)
.with_traceparent(traceparent)
.build()?;
let attribs = msg.attributes();
assert_eq!(attribs.traceparent(), Some(traceparent));Sourcepub fn request_id(&self) -> Option<&UUID>
pub fn request_id(&self) -> Option<&UUID>
Gets the request identifier of the message these attributes belong to.
§Example
use up_rust::{UCode, UMessageBuilder, UUID, UUri};
let request_id = UUID::build();
let invoked_method = UUri::try_from("//my-vehicle/D45/2/101")?;
let reply_to = UUri::try_from("//other-vehicle/D10/3/0")?;
let msg = UMessageBuilder::response(reply_to, request_id.clone(), invoked_method)
.build()?;
let attribs = msg.attributes();
assert_eq!(attribs.request_id(), Some(&request_id));Sourcepub fn request_id_unchecked(&self) -> &UUID
pub fn request_id_unchecked(&self) -> &UUID
Gets the request identifier of the message these attributes belong to.
§Panics
if the property has no value.
§Example
use up_rust::{UCode, UMessageBuilder, UUID, UUri};
let request_id = UUID::build();
let invoked_method = UUri::try_from("//my-vehicle/D45/2/101")?;
let reply_to = UUri::try_from("//other-vehicle/D10/3/0")?;
let msg = UMessageBuilder::response(reply_to, request_id.clone(), invoked_method)
.build()?;
let attribs = msg.attributes();
assert_eq!(attribs.request_id_unchecked(), &request_id);Sourcepub fn payload_format(&self) -> Option<UPayloadFormat>
pub fn payload_format(&self) -> Option<UPayloadFormat>
Gets the payload format of the message these attributes belong to.
§Example
use up_rust::{UMessageBuilder, UPayloadFormat, UUri};
let topic = UUri::try_from("//my-vehicle/D45/23/A001")?;
let msg = UMessageBuilder::publish(topic)
.build_with_payload("hello".as_bytes(), UPayloadFormat::Text)?;
let attribs = msg.attributes();
assert_eq!(attribs.payload_format(), Some(UPayloadFormat::Text));Sourcepub fn open_payload_encoding_parts(
&self,
) -> (Option<u32>, Option<&str>, Option<&str>)
pub fn open_payload_encoding_parts( &self, ) -> (Option<u32>, Option<&str>, Option<&str>)
Gets the open payload-encoding identity components for encodings that
do not have a legacy UPayloadFormat equivalent.
Sourcepub fn payload_format_unchecked(&self) -> UPayloadFormat
pub fn payload_format_unchecked(&self) -> UPayloadFormat
Gets the payload format of the message these attributes belong to.
§Panics
if the property has no value.
§Example
use up_rust::{UMessageBuilder, UPayloadFormat, UUri};
let topic = UUri::try_from("//my-vehicle/D45/23/A001")?;
let msg = UMessageBuilder::publish(topic)
.build_with_payload("hello".as_bytes(), UPayloadFormat::Text)?;
let attribs = msg.attributes();
assert_eq!(attribs.payload_format_unchecked(), UPayloadFormat::Text);Sourcepub fn is_publish(&self) -> bool
pub fn is_publish(&self) -> bool
Checks if these are the attributes for a Publish message.
§Examples
use up_rust::{UMessageBuilder, UUri};
let topic = UUri::try_from("//my-vehicle/D45/23/A001")?;
let msg = UMessageBuilder::publish(topic).build()?;
let attribs = msg.attributes();
assert!(attribs.is_publish());Sourcepub fn is_request(&self) -> bool
pub fn is_request(&self) -> bool
Checks if these are the attributes for an RPC Request message.
§Examples
use up_rust::{UMessageBuilder, UUri};
let invoked_method = UUri::try_from("//my-vehicle/D45/2/101")?;
let reply_to = UUri::try_from("//other-vehicle/D10/3/0")?;
let msg = UMessageBuilder::request(invoked_method, reply_to, 5000)
.build()?;
let attribs = msg.attributes();
assert!(attribs.is_request());Sourcepub fn is_response(&self) -> bool
pub fn is_response(&self) -> bool
Checks if these are the attributes for an RPC Response message.
§Examples
use up_rust::{UCode, UMessageBuilder, UUID, UUri};
let invoked_method = UUri::try_from("//my-vehicle/D45/2/101")?;
let reply_to = UUri::try_from("//other-vehicle/D10/3/0")?;
let msg = UMessageBuilder::response(reply_to, UUID::build(), invoked_method)
.build()?;
let attribs = msg.attributes();
assert!(attribs.is_response());Sourcepub fn is_notification(&self) -> bool
pub fn is_notification(&self) -> bool
Checks if these are the attributes for a Notification message.
§Examples
use up_rust::{UMessageBuilder, UUri};
let origin = UUri::try_from("//my-vehicle/D45/23/A001")?;
let dest = UUri::try_from("//other-vehicle/D10/3/0")?;
let msg = UMessageBuilder::notification(origin, dest).build()?;
let attribs = msg.attributes();
assert!(attribs.is_notification());Sourcepub fn check_expired(&self) -> Result<(), UAttributesError>
pub fn check_expired(&self) -> Result<(), UAttributesError>
Checks if the message that is described by these attributes should be considered expired.
§Errors
Returns an error if Self::ttl (time-to-live) contains a value greater than 0, but
- the current system time cannot be determined, or
- the message has expired according to the timestamp extracted from
Self::idand the time-to-live value.
Sourcepub fn check_expired_for_reference(
&self,
reference_time: u128,
) -> Result<(), UAttributesError>
pub fn check_expired_for_reference( &self, reference_time: u128, ) -> Result<(), UAttributesError>
Checks if the message that is described by these attributes should be considered expired.
§Arguments
reference_time- The reference time as aDurationsince UNIX epoch. The check will be performed in relation to this point in time.
§Errors
Returns an error if Self::ttl (time-to-live) contains a value greater than 0, but
the message has expired according to the timestamp extracted from Self::id, the
time-to-live value and the provided reference time.
Source§impl UAttributes
impl UAttributes
Sourcepub fn to_frame_metadata(
&self,
payload_encoding: PayloadEncoding,
) -> Result<UFrameMetadata, UFrameMetadataError>
pub fn to_frame_metadata( &self, payload_encoding: PayloadEncoding, ) -> Result<UFrameMetadata, UFrameMetadataError>
Projects these attributes to frame metadata carrying the given payload encoding.
Convenience for try_project_attributes_to_frame_metadata; use
Self::to_frame_metadata_unencoded when the message carries no
payload.
§Errors
Returns an error if the attributes and encoding disagree or the resulting metadata is invalid.
Sourcepub fn to_frame_metadata_unencoded(
&self,
) -> Result<UFrameMetadata, UFrameMetadataError>
pub fn to_frame_metadata_unencoded( &self, ) -> Result<UFrameMetadata, UFrameMetadataError>
Projects these attributes to frame metadata for a payload-free message.
§Errors
Returns an error if the attributes carry payload information or the resulting metadata is invalid.
Trait Implementations§
Source§impl Clone for UAttributes
impl Clone for UAttributes
Source§fn clone(&self) -> UAttributes
fn clone(&self) -> UAttributes
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more