pub struct StaticUriProvider { /* private fields */ }
Expand description
A URI provider that is statically configured with the uEntity’s authority, entity ID and version.
Implementations§
Source§impl StaticUriProvider
impl StaticUriProvider
Sourcepub fn new(
authority: impl Into<String>,
entity_id: u32,
major_version: u8,
) -> Self
pub fn new( authority: impl Into<String>, entity_id: u32, major_version: u8, ) -> Self
Creates a new URI provider from static information.
§Arguments
authority
- The uEntity’s authority name.entity_id
- The entity identifier.major_version
- The uEntity’s major version.
§Examples
use up_rust::{LocalUriProvider, StaticUriProvider};
let provider = StaticUriProvider::new("my-vehicle", 0x4210, 0x05);
assert_eq!(provider.get_authority(), "my-vehicle");
Trait Implementations§
Source§impl LocalUriProvider for StaticUriProvider
impl LocalUriProvider for StaticUriProvider
Gets the authority used for URIs representing this uEntity’s resources.
Source§fn get_resource_uri(&self, resource_id: u16) -> UUri
fn get_resource_uri(&self, resource_id: u16) -> UUri
Gets a URI that represents a given resource of this uEntity.
Source§fn get_source_uri(&self) -> UUri
fn get_source_uri(&self) -> UUri
Gets the URI that represents the resource that this uEntity expects
RPC responses and notifications to be sent to.
Source§impl TryFrom<&UUri> for StaticUriProvider
impl TryFrom<&UUri> for StaticUriProvider
Source§fn try_from(source_uri: &UUri) -> Result<Self, Self::Error>
fn try_from(source_uri: &UUri) -> Result<Self, Self::Error>
Creates a URI provider from a UUri.
§Arguments
source_uri
- The UUri to take the entity’s authority, entity ID and version information from. The UUri’s resource ID is ignored.
§Errors
Returns an error if the given UUri’s major version property is not a u8
.
§Examples
use up_rust::{LocalUriProvider, StaticUriProvider, UUri};
let source_uri = UUri::try_from("//my-vehicle/4210/5/0").unwrap();
assert!(StaticUriProvider::try_from(&source_uri).is_ok());
§Invalid Major Version
use up_rust::{LocalUriProvider, StaticUriProvider, UUri};
let uuri_with_invalid_version = UUri {
authority_name: "".to_string(),
ue_id: 0x5430,
ue_version_major: 0x1234, // not a u8
resource_id: 0x0000,
..Default::default()
};
assert!(StaticUriProvider::try_from(uuri_with_invalid_version).is_err());
Source§type Error = TryFromIntError
type Error = TryFromIntError
The type returned in the event of a conversion error.
Auto Trait Implementations§
impl !Freeze for StaticUriProvider
impl RefUnwindSafe for StaticUriProvider
impl Send for StaticUriProvider
impl Sync for StaticUriProvider
impl Unpin for StaticUriProvider
impl UnwindSafe for StaticUriProvider
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
Mutably borrows from an owned value. Read more