[−][src]Struct rupnp::Service
A UPnP Service is the description of endpoints on a device for performing actions and reading
the service definition.
For a list of actions and state variables the service provides, take a look at scpd.
Methods
impl Service[src]
pub fn service_type(&self) -> &URN[src]
Returns the URN of this service.
pub fn service_id(&self) -> &str[src]
Returns the Service Identifier.
pub async fn scpd<'_, '_>(&'_ self, url: &'_ Uri) -> Result<SCPD, Error>[src]
Fetches the SCPD of this service.
pub async fn action<'_, '_, '_, '_>(
&'_ self,
url: &'_ Uri,
action: &'_ str,
payload: &'_ str
) -> Result<HashMap<String, String>, Error>[src]
&'_ self,
url: &'_ Uri,
action: &'_ str,
payload: &'_ str
) -> Result<HashMap<String, String>, Error>
Execute some UPnP Action on this service. The URL is usually obtained by the device this service was found on. The payload is xml-formatted data.
Example usage:
use upnp::ssdp::URN; use upnp::Device; let urn = URN::service("schemas-upnp-org", "RenderingControl", 1); let device = Device::from_url( some_url ).await?; let service = device.find_service(&urn) .expect("service exists"); let args = "<InstanceID>0</InstanceID><Channel>Master</Channel>"; let response = service.action(device.url(), "GetVolume", args).await?; let volume = response .get("CurrentVolume") .expect("exists"); println!("Volume: {}", volume);
pub async fn subscribe<'_, '_>(
&'_ self,
url: &'_ Uri,
timeout_secs: u32
) -> Result<(String, impl Stream<Item = Result<HashMap<String, String>, Error>>), Error>[src]
&'_ self,
url: &'_ Uri,
timeout_secs: u32
) -> Result<(String, impl Stream<Item = Result<HashMap<String, String>, Error>>), Error>
Subscribe for state variable changes.
It returns the SID which can be used to unsubscribe to the service and a stream of responses.
Each response is a HashMap of the state variables.
Example usage:
let (_sid, stream) = service.subscribe(device.url(), 300).await?; while let Some(state_vars) = stream.try_next().await? { for (key, value) in state_vars { println!("{} => {}", key, value); } }
pub async fn renew_subscription<'_, '_, '_>(
&'_ self,
url: &'_ Uri,
sid: &'_ str,
timeout_secs: u32
) -> Result<(), Error>[src]
&'_ self,
url: &'_ Uri,
sid: &'_ str,
timeout_secs: u32
) -> Result<(), Error>
Renew a subscription made with the subscribe method.
When the sid is invalid, the control point will respond with a 412 Preconditition failed.
pub async fn unsubscribe<'_, '_, '_>(
&'_ self,
url: &'_ Uri,
sid: &'_ str
) -> Result<(), Error>[src]
&'_ self,
url: &'_ Uri,
sid: &'_ str
) -> Result<(), Error>
Unsubscribe from further event notifications.
The SID is usually obtained by the subscribe method.
When the sid is invalid, the control point will respond with a 412 Preconditition failed.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Service
impl Send for Service
impl Sync for Service
impl Unpin for Service
impl UnwindSafe for Service
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,