Skip to main content

Fetchable

Trait Fetchable 

Source
pub trait Fetchable: SonosProperty {
    type Operation: UPnPOperation;

    // Required methods
    fn build_operation(    ) -> Result<ComposableOperation<Self::Operation>, SdkError>;
    fn from_response(
        response: <Self::Operation as UPnPOperation>::Response,
    ) -> Self;
}
Expand description

Trait for properties that can be fetched from the device

This trait defines how to fetch a property value from a Sonos device. Each property type that supports fetching must implement this trait.

§Type Parameters

  • Op: The UPnP operation type used to fetch this property

§Example

impl Fetchable for Volume {
    type Operation = GetVolumeOperation;

    fn build_operation() -> Result<ComposableOperation<Self::Operation>, SdkError> {
        rendering_control::get_volume_operation("Master".to_string())
            .build()
            .map_err(|e| SdkError::FetchFailed(e.to_string()))
    }

    fn from_response(response: GetVolumeResponse) -> Self {
        Volume::new(response.current_volume)
    }
}

Required Associated Types§

Source

type Operation: UPnPOperation

The UPnP operation type used to fetch this property

Required Methods§

Source

fn build_operation() -> Result<ComposableOperation<Self::Operation>, SdkError>

Build the operation to fetch this property

Source

fn from_response(response: <Self::Operation as UPnPOperation>::Response) -> Self

Convert the operation response to the property value

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.

Implementations on Foreign Types§

Source§

impl Fetchable for Bass

Source§

impl Fetchable for CurrentTrack

Source§

impl Fetchable for Loudness

Source§

impl Fetchable for Mute

Source§

impl Fetchable for Position

Source§

impl Fetchable for Treble

Implementors§