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

Struct ExactUUri

Source
pub struct ExactUUri(/* private fields */);
Expand description

A UUri that has been checked to contain no wildcard components.

This proof type is for APIs where exact-vs-wildcard URI behavior is materially different. It only carries the result of UUri::verify_no_wildcards; it does not imply physical transport prefiltering or no-copy behavior.

Implementations§

Source§

impl ExactUUri

Source

pub fn try_new(uri: UUri) -> Result<Self, UUriError>

Creates an exact URI proof from a URI with no wildcard components.

§Errors

Returns the same validation error as UUri::verify_no_wildcards when any URI component contains a wildcard.

Source

pub fn as_uuri(&self) -> &UUri

Borrows the checked URI.

Source

pub fn into_inner(self) -> UUri

Consumes this proof and returns the underlying URI.

Methods from Deref<Target = UUri>§

Source

pub fn to_uri(&self, include_scheme: bool) -> String

Serializes this UUri to a URI string.

§Arguments
  • include_scheme - Indicates whether to include the uProtocol scheme (up) in the URI.
§Returns

The URI as defined by the uProtocol Specification.

§Examples
use up_rust::UUri;

let uuri = UUri::try_from_parts("vin.vehicles", 0x0000_800A, 0x02, 0x1a50).unwrap();
let uri_string = uuri.to_uri(true);
assert_eq!(uri_string, "up://vin.vehicles/800A/2/1A50");
Source

pub fn authority_name(&self) -> &str

Gets the authority name part from this uProtocol URI.

§Examples
use up_rust::UUri;

let uri = UUri::try_from_parts("my-vehicle", 0x10101234, 0x01, 0x9a10).unwrap();
assert_eq!(uri.authority_name(), "my-vehicle");
Source

pub fn uentity_type_id(&self) -> u16

§Examples
use up_rust::UUri;

let uri = UUri::try_from_parts("my-vehicle", 0x10101234, 0x01, 0x9a10).unwrap();
assert_eq!(uri.uentity_type_id(), 0x1234);
Source

pub fn uentity_instance_id(&self) -> u16

§Examples
use up_rust::UUri;

let uri = UUri::try_from_parts("my-vehicle", 0x10101234, 0x01, 0x9a10).unwrap();
assert_eq!(uri.uentity_instance_id(), 0x1010);
Source

pub fn uentity_major_version(&self) -> u8

§Examples
use up_rust::UUri;

let uri = UUri::try_from_parts("my-vehicle", 0x10101234, 0x01, 0x9a10).unwrap();
assert_eq!(uri.uentity_major_version(), 0x01);
Source

pub fn resource_id(&self) -> u16

§Examples
use up_rust::UUri;

let uri = UUri::try_from_parts("my-vehicle", 0x10101234, 0x01, 0x9a10).unwrap();
assert_eq!(uri.resource_id(), 0x9a10);
Source

pub fn clone_with_resource_id(&self, resource_id: u16) -> Self

Returns a copy of this URI with the resource id replaced.

Source

pub fn is_remote(&self, other_uri: &UUri) -> bool

Check if an UUri is remote, by comparing authority fields. UUris with empty authority are considered to be local.

§Returns

‘true’ if other_uri has a different authority than Self, false otherwise.

§Examples
use std::str::FromStr;
use up_rust::UUri;

let authority_a = UUri::from_str("up://authority.a/100A/1/0").unwrap();
let authority_b = UUri::from_str("up://authority.b/200B/2/20").unwrap();
assert!(authority_a.is_remote(&authority_b));

let authority_local = UUri::from_str("up:///100A/1/0").unwrap();
assert!(!authority_local.is_remote(&authority_a));

let authority_wildcard = UUri::from_str("up://*/100A/1/0").unwrap();
assert!(!authority_wildcard.is_remote(&authority_a));
assert!(!authority_a.is_remote(&authority_wildcard));
assert!(!authority_wildcard.is_remote(&authority_wildcard));
Source

pub fn is_remote_authority(&self, authority: &str) -> bool

Check if an authority is remote compared to the authority field of the UUri. Empty authorities are considered to be local.

§Returns

‘true’ if authority is a different than Self.authority_name, false otherwise.

§Examples
use std::str::FromStr;
use up_rust::UUri;

let authority_a = UUri::from_str("up://authority.a/100A/1/0").unwrap();
let authority_b = "authority.b";
assert!(authority_a.is_remote_authority(&authority_b));

let authority_local = "";
assert!(!authority_a.is_remote_authority(&authority_local));

let authority_wildcard = "*";
assert!(!authority_a.is_remote_authority(&authority_wildcard));
Source

pub fn has_empty_authority(&self) -> bool

Checks if this UUri has an empty authority name.

§Examples
use up_rust::UUri;

let uuri = UUri::try_from_parts("", 0x9b3a, 0x01, 0x145b).unwrap();
assert!(uuri.has_empty_authority());
Source

pub fn has_wildcard_authority(&self) -> bool

Checks if this UUri has a wildcard authority name.

§Examples
use up_rust::UUri;

let uuri = UUri::try_from_parts("*", 0x9b3a, 0x01, 0x145b).unwrap();
assert!(uuri.has_wildcard_authority());
Source

pub fn has_wildcard_entity_instance(&self) -> bool

Checks if this UUri has an entity identifier matching any instance.

§Examples
use up_rust::UUri;

let uuri = UUri::try_from_parts("vin", 0xFFFF_0123, 0x01, 0x145b).unwrap();
assert!(uuri.has_wildcard_entity_instance());
Source

pub fn has_wildcard_entity_type(&self) -> bool

Checks if this UUri has an entity identifier matching any type.

§Examples
use up_rust::UUri;

let uuri = UUri::try_from_parts("vin", 0x00C0_FFFF, 0x01, 0x145b).unwrap();
assert!(uuri.has_wildcard_entity_type());
Source

pub fn has_wildcard_version(&self) -> bool

Checks if this UUri has a wildcard major version.

§Examples
use up_rust::UUri;

let uuri = UUri::try_from_parts("vin", 0x9b3a, 0xFF, 0x145b).unwrap();
assert!(uuri.has_wildcard_version());
Source

pub fn has_wildcard_resource_id(&self) -> bool

Checks if this UUri has a wildcard entity identifier.

§Examples
use up_rust::UUri;

let uuri = UUri::try_from_parts("vin", 0x9b3a, 0x01, 0xFFFF).unwrap();
assert!(uuri.has_wildcard_resource_id());
Source

pub fn verify_no_wildcards(&self) -> Result<(), UUriError>

Verifies that this UUri does not contain any wildcards.

§Errors

Returns an error if any of this UUri’s properties contain a wildcard value.

§Examples
use up_rust::UUri;

let uri = UUri::try_from_parts("vin.vehicles", 0x0000_2310, 0x03, 0xa000).unwrap();
assert!(uri.verify_no_wildcards().is_ok());
Source

pub fn is_rpc_method(&self) -> bool

Checks if this UUri refers to a service method.

Returns true if 0 < resource ID < 0x8000.

§Examples
use up_rust::UUri;

let uri = UUri::try_from_parts("", 0xabcd, 0x01, 0x7FFF).unwrap();
assert!(uri.is_rpc_method());
Source

pub fn verify_rpc_method(&self) -> Result<(), UUriError>

Verifies that this UUri refers to a service method.

§Errors

Returns an error if Self::is_rpc_method fails or the UUri contains any wildcards.

§Examples
use up_rust::UUri;

let uri = UUri::try_from_parts("", 0xabcd, 0x01, 0x8000).unwrap();
assert!(uri.verify_rpc_method().is_err());

let uri = UUri::try_from_parts("", 0xabcd, 0x01, 0x0000).unwrap();
assert!(uri.verify_rpc_method().is_err());
Source

pub fn is_notification_destination(&self) -> bool

Checks if this UUri represents a destination for a Notification.

Returns true if resource ID is 0.

§Examples
use up_rust::UUri;

let uri = UUri::try_from_parts("", 0xabcd, 0x01, 0x0000).unwrap();
assert!(uri.is_notification_destination());
Source

pub fn is_rpc_response(&self) -> bool

Checks if this UUri represents an RPC response address.

Returns true if resource ID is 0.

§Examples
use up_rust::UUri;

let uri = UUri::try_from_parts("", 0xabcd, 0x01, 0x0000).unwrap();
assert!(uri.is_rpc_response());
Source

pub fn verify_rpc_response(&self) -> Result<(), UUriError>

Verifies that this UUri represents an RPC response address.

§Errors

Returns an error if Self::is_rpc_response fails or the UUri contains any wildcards.

§Examples
use up_rust::UUri;

let uri = UUri::try_from_parts("", 0xabcd, 0x01, 0x4001).unwrap();
assert!(uri.verify_rpc_response().is_err());
Source

pub fn is_event(&self) -> bool

Checks if this UUri can be used as the source of an event.

Returns true if resource ID >= 0x8000.

§Examples
use up_rust::UUri;

let uri = UUri::try_from_parts("", 0xabcd, 0x01, 0x8000).unwrap();
assert!(uri.is_event());
Source

pub fn verify_event(&self) -> Result<(), UUriError>

Verifies that this UUri can be used as the source of an event.

§Errors

Returns an error if Self::is_event fails or the UUri contains any wildcards.

§Examples
use up_rust::UUri;

let uri = UUri::try_from_parts("", 0xabcd, 0x01, 0x7FFF).unwrap();
assert!(uri.verify_event().is_err());
Source

pub fn matches(&self, candidate: &UUri) -> bool

Checks if a given candidate URI matches a pattern.

§Returns

true if the candiadate matches the pattern represented by this UUri.

§Examples
use up_rust::UUri;

let pattern = UUri::try_from("//vin/A14F/3/FFFF").unwrap();
let candidate = UUri::try_from("//vin/A14F/3/B1D4").unwrap();
assert!(pattern.matches(&candidate));

Trait Implementations§

Source§

impl AsRef<UUri> for ExactUUri

Source§

fn as_ref(&self) -> &UUri

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for ExactUUri

Source§

fn clone(&self) -> ExactUUri

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 ExactUUri

Source§

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

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

impl Deref for ExactUUri

Source§

type Target = UUri

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl From<ExactUUri> for UUri

Source§

fn from(value: ExactUUri) -> Self

Converts to this type from the input type.
Source§

impl Hash for ExactUUri

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ExactUUri

Source§

fn eq(&self, other: &ExactUUri) -> 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 TryFrom<&UUri> for ExactUUri

Source§

type Error = UUriError

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

fn try_from(value: &UUri) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<UUri> for ExactUUri

Source§

type Error = UUriError

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

fn try_from(value: UUri) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for ExactUUri

Source§

impl StructuralPartialEq for ExactUUri

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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