pub enum UAttributesValidators {
Publish,
Notification,
Request,
Response,
}
Expand description
Enum that hold the implementations of uattributesValidator according to type.
Variants§
Implementations§
Source§impl UAttributesValidators
impl UAttributesValidators
Sourcepub fn validator(&self) -> Box<dyn UAttributesValidator>
pub fn validator(&self) -> Box<dyn UAttributesValidator>
Gets the validator corresponding to this enum value.
§Examples
use up_rust::{UAttributes, UAttributesValidators, UMessageBuilder, UMessageType, UUID, UUri};
let topic = UUri::try_from("//my-vehicle/D45/23/A001")?;
let attributes = UAttributes {
type_: UMessageType::UMESSAGE_TYPE_PUBLISH.into(),
id: Some(UUID::build()).into(),
source: Some(topic).into(),
..Default::default()
};
let validator = UAttributesValidators::Publish.validator();
assert!(validator.validate(&attributes).is_ok());
Sourcepub fn get_validator_for_attributes(
attributes: &UAttributes,
) -> Box<dyn UAttributesValidator>
pub fn get_validator_for_attributes( attributes: &UAttributes, ) -> Box<dyn UAttributesValidator>
Gets a validator that can be used to check a given set of attributes.
§Examples
use up_rust::{UAttributes, UAttributesValidators, UMessageBuilder, UMessageType, UUID, UUri};
let topic = UUri::try_from("//my-vehicle/D45/23/A001")?;
let attributes = UAttributes {
type_: UMessageType::UMESSAGE_TYPE_PUBLISH.into(),
id: Some(UUID::build()).into(),
source: Some(topic).into(),
..Default::default()
};
let validator = UAttributesValidators::get_validator_for_attributes(&attributes);
assert!(validator.validate(&attributes).is_ok());
Sourcepub fn get_validator(
message_type: UMessageType,
) -> Box<dyn UAttributesValidator>
pub fn get_validator( message_type: UMessageType, ) -> Box<dyn UAttributesValidator>
Gets a validator that can be used to check attributes of a given type of message.
§Examples
use up_rust::{UAttributes, UAttributesValidators, UMessageBuilder, UMessageType, UUID, UUri};
let topic = UUri::try_from("//my-vehicle/D45/23/A001")?;
let attributes = UAttributes {
type_: UMessageType::UMESSAGE_TYPE_PUBLISH.into(),
id: Some(UUID::build()).into(),
source: Some(topic).into(),
..Default::default()
};
let validator = UAttributesValidators::get_validator(UMessageType::UMESSAGE_TYPE_PUBLISH);
assert!(validator.validate(&attributes).is_ok());
Auto Trait Implementations§
impl Freeze for UAttributesValidators
impl RefUnwindSafe for UAttributesValidators
impl Send for UAttributesValidators
impl Sync for UAttributesValidators
impl Unpin for UAttributesValidators
impl UnwindSafe for UAttributesValidators
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