[−][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
.
Implementations
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 rupnp::ssdp::URN; use rupnp::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
[src]
impl Send for Service
[src]
impl Sync for Service
[src]
impl Unpin for Service
[src]
impl UnwindSafe for Service
[src]
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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[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.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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>,