Trait up_rust::UAttributesValidator
source · pub trait UAttributesValidator: Send {
// Required methods
fn validate(&self, attributes: &UAttributes) -> Result<(), UAttributesError>;
fn message_type(&self) -> UMessageType;
fn validate_source(
&self,
attributes: &UAttributes,
) -> Result<(), UAttributesError>;
fn validate_sink(
&self,
attributes: &UAttributes,
) -> Result<(), UAttributesError>;
// Provided methods
fn validate_type(
&self,
attributes: &UAttributes,
) -> Result<(), UAttributesError> { ... }
fn validate_id(
&self,
attributes: &UAttributes,
) -> Result<(), UAttributesError> { ... }
fn is_expired(
&self,
attributes: &UAttributes,
) -> Result<(), UAttributesError> { ... }
}Expand description
UAttributes is the struct that defines the Payload. It serves as the configuration for various aspects
like time to live, priority, security tokens, and more. Each variant of UAttributes defines a different
type of message payload. The payload could represent a simple published payload with some state change,
an RPC request payload, or an RPC response payload.
UAttributesValidator is a trait implemented by all validators for UAttributes. It provides functionality
to help validate that a given UAttributes instance is correctly configured to define the Payload.
Required Methods§
sourcefn validate(&self, attributes: &UAttributes) -> Result<(), UAttributesError>
fn validate(&self, attributes: &UAttributes) -> Result<(), UAttributesError>
Checks if a given set of attributes complies with the rules specified for the type of message they describe.
§Errors
Returns an error if the attributes are not consistent with the rules specified for the message type.
sourcefn message_type(&self) -> UMessageType
fn message_type(&self) -> UMessageType
Returns the type of message that this validator can be used with.
sourcefn validate_source(
&self,
attributes: &UAttributes,
) -> Result<(), UAttributesError>
fn validate_source( &self, attributes: &UAttributes, ) -> Result<(), UAttributesError>
Verifies that a set of attributes contains a valid source URI.
§Errors
If the UAttributes::source property does not contain a valid URI as required by the type of message, an error is returned.
sourcefn validate_sink(
&self,
attributes: &UAttributes,
) -> Result<(), UAttributesError>
fn validate_sink( &self, attributes: &UAttributes, ) -> Result<(), UAttributesError>
Verifies that a set of attributes contains a valid sink URI.
Provided Methods§
sourcefn validate_type(
&self,
attributes: &UAttributes,
) -> Result<(), UAttributesError>
fn validate_type( &self, attributes: &UAttributes, ) -> Result<(), UAttributesError>
Verifies that this validator is appropriate for a set of attributes.
§Errors
Returns an error if UAttributes::type_ does not match the type returned by UAttributesValidator::message_type.
sourcefn validate_id(&self, attributes: &UAttributes) -> Result<(), UAttributesError>
fn validate_id(&self, attributes: &UAttributes) -> Result<(), UAttributesError>
Verifies that a set of attributes contains a valid message ID.
§Errors
Returns an error if UAttributes::id does not contain a valid uProtocol UUID.
sourcefn is_expired(&self, attributes: &UAttributes) -> Result<(), UAttributesError>
fn is_expired(&self, attributes: &UAttributes) -> Result<(), UAttributesError>
Checks if the message that is described by these attributes should be considered expired.
§Errors
Returns an error if UAttributes::ttl (time-to-live) contains a value greater than 0, but
- the message has expired according to the timestamp extracted from
UAttributes::idand the time-to-live value, or - the current system time cannot be determined.