Preview of the proposed up-rust native-frame-model branch (up-rust b6b99c6d, up-spec f0e9b17) — not released documentation. branch · write-up

Struct UAttributes

Source
#[repr(C)]
pub struct UAttributes { /* private fields */ }
Expand description

Message metadata: addressing, identity, type, and delivery options for one UMessage.

Implementations§

Source§

impl UAttributes

Source

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);
Source

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);
Source

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);
Source

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));
Source

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);
Source

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));
Source

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);
Source

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));
Source

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);
Source

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));
Source

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);
Source

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));
Source

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));
Source

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));
Source

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));
Source

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);
Source

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));
Source

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.

Source

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);
Source

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());
Source

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());
Source

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());
Source

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());
Source

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::id and the time-to-live value.
Source

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 a Duration since 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

Source

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.

Source

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

Source§

fn clone(&self) -> UAttributes

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UAttributes

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for UAttributes

Source§

fn eq(&self, other: &UAttributes) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ProtobufMappable for UAttributes

Source§

fn parse_from_protobuf_bytes(proto: &[u8]) -> Result<Self, SerializationError>

Parses an instance of this type from the given protobuf bytes. Read more
Source§

fn parse_from_packed_protobuf_bytes( proto: &[u8], ) -> Result<Self, SerializationError>

Parses an instance of this type from the given packed protobuf bytes. Read more
Source§

fn write_to_protobuf_bytes(&self) -> Result<Vec<u8>, SerializationError>

Serializes this instance to protobuf bytes. Read more
Source§

fn write_to_packed_protobuf_bytes(&self) -> Result<Vec<u8>, SerializationError>

Serializes this instance to packed protobuf bytes. Read more
Source§

impl StructuralPartialEq for UAttributes

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<TCore> UWithNativePrefixWire for TCore

Source§

fn into_native_prefix_wire_transport<W>( self, wire: W, ) -> UWireTransport<TCore, W, NativePrefixFrameMetadataCodec>
where W: UWire,

Wraps this core with an external or custom selected wire using canonical metadata.
Source§

fn into_protobuf_transport( self, ) -> UWireTransport<TCore, ProtobufWire, NativePrefixFrameMetadataCodec>

Wraps this core with the Protocol Buffers selected-wire profile.
Source§

fn into_stable_container_transport( self, ) -> UWireTransport<TCore, StableContainerWireFormat, NativePrefixFrameMetadataCodec>

Wraps this core with the stable-container selected-wire profile.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more