pub trait SonosOperation {
type Request: Serialize;
type Response: for<'de> Deserialize<'de>;
const SERVICE: Service;
const ACTION: &'static str;
// Required methods
fn build_payload(request: &Self::Request) -> String;
fn parse_response(xml: &Element) -> Result<Self::Response, ApiError>;
}Expand description
Base trait for all Sonos API operations (LEGACY)
This trait defines the common interface that all Sonos UPnP operations must implement. It provides type safety through associated types and ensures consistent patterns for request/response handling across all operations.
Note: This is the legacy trait. New code should use UPnPOperation instead.
Required Associated Constants§
Required Associated Types§
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) -> String
fn build_payload(request: &Self::Request) -> String
Build the SOAP payload from the request data
This method should construct the XML payload that goes inside the SOAP envelope. The payload should contain all the parameters needed for the UPnP action.
§Arguments
request- The typed request data
§Returns
A string containing the XML payload (without SOAP envelope)
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
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.