pub trait UPnPOperation {
type Request: Serialize + Validate;
type Response: for<'de> Deserialize<'de>;
const SERVICE: Service;
const ACTION: &'static str;
// Required methods
fn build_payload(request: &Self::Request) -> Result<String, ValidationError>;
fn parse_response(xml: &Element) -> Result<Self::Response, ApiError>;
// Provided methods
fn dependencies() -> &'static [&'static str] { ... }
fn can_batch_with<T: UPnPOperation>() -> bool { ... }
fn metadata() -> OperationMetadata { ... }
}Expand description
Enhanced UPnP operation trait with composability support
This trait extends the original SonosOperation concept with:
- Composability: operations can be chained, batched, or made conditional
- Validation: flexible validation strategy with boundary and comprehensive levels
- Dependencies: operations can declare dependencies on other operations
- Batching: operations can indicate whether they can be batched with others
Required Associated Constants§
Required Associated Types§
Sourcetype Request: Serialize + Validate
type Request: Serialize + Validate
The request type for this operation, must be serializable and validatable
Sourcetype Response: for<'de> Deserialize<'de>
type Response: for<'de> Deserialize<'de>
The response type for this operation, must be deserializable
Required Methods§
Sourcefn build_payload(request: &Self::Request) -> Result<String, ValidationError>
fn build_payload(request: &Self::Request) -> Result<String, ValidationError>
Sourcefn parse_response(xml: &Element) -> Result<Self::Response, ApiError>
fn parse_response(xml: &Element) -> Result<Self::Response, ApiError>
Parse the SOAP response XML into the typed response
This method extracts the relevant data from the SOAP response XML and converts it into the strongly-typed response structure.
§Arguments
xml- The parsed XML element containing the response data
§Returns
The typed response data or an error if parsing fails
Provided Methods§
Sourcefn dependencies() -> &'static [&'static str]
fn dependencies() -> &'static [&'static str]
Get the list of operations this operation depends on
This is used for operation ordering and dependency resolution in batch and sequence operations.
§Returns
A slice of action names that must be executed before this operation
Sourcefn can_batch_with<T: UPnPOperation>() -> bool
fn can_batch_with<T: UPnPOperation>() -> bool
Check if this operation can be batched with another operation
Some operations may have conflicts or dependencies that prevent them from being executed in parallel.
§Type Parameters
T- Another UPnP operation type to check compatibility with
§Returns
True if the operations can be safely executed in parallel
Sourcefn metadata() -> OperationMetadata
fn metadata() -> OperationMetadata
Get human-readable operation metadata
This is useful for debugging, logging, and SDK development
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.