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
impl ExactUUri
Sourcepub fn try_new(uri: UUri) -> Result<Self, UUriError>
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.
Sourcepub fn into_inner(self) -> UUri
pub fn into_inner(self) -> UUri
Consumes this proof and returns the underlying URI.
Methods from Deref<Target = UUri>§
Sourcepub fn to_uri(&self, include_scheme: bool) -> String
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");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");Sourcepub fn uentity_type_id(&self) -> u16
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);Sourcepub fn uentity_instance_id(&self) -> u16
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);Sourcepub fn uentity_major_version(&self) -> u8
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);Sourcepub fn resource_id(&self) -> u16
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);Sourcepub fn clone_with_resource_id(&self, resource_id: u16) -> Self
pub fn clone_with_resource_id(&self, resource_id: u16) -> Self
Returns a copy of this URI with the resource id replaced.
Sourcepub fn is_remote(&self, other_uri: &UUri) -> bool
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));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));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());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());Sourcepub fn has_wildcard_entity_instance(&self) -> bool
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());Sourcepub fn has_wildcard_entity_type(&self) -> bool
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());Sourcepub fn has_wildcard_version(&self) -> bool
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());Sourcepub fn has_wildcard_resource_id(&self) -> bool
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());Sourcepub fn verify_no_wildcards(&self) -> Result<(), UUriError>
pub fn verify_no_wildcards(&self) -> Result<(), UUriError>
Sourcepub fn is_rpc_method(&self) -> bool
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());Sourcepub fn verify_rpc_method(&self) -> Result<(), UUriError>
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());Sourcepub fn is_notification_destination(&self) -> bool
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());Sourcepub fn is_rpc_response(&self) -> bool
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());Sourcepub fn verify_rpc_response(&self) -> Result<(), UUriError>
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());Sourcepub fn is_event(&self) -> bool
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());Sourcepub fn verify_event(&self) -> Result<(), UUriError>
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());Sourcepub fn matches(&self, candidate: &UUri) -> bool
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));