Skip to main content

SoapClient

Struct SoapClient 

Source
pub struct SoapClient { /* private fields */ }
Expand description

A minimal SOAP client for UPnP device communication

Uses Arc internally for efficient sharing of the underlying HTTP client and connection pool across multiple instances.

Implementations§

Source§

impl SoapClient

Source

pub fn get() -> &'static Self

Get the global shared SOAP client instance

This provides a singleton-like pattern for maximum resource efficiency. All clients returned by this method share the same underlying HTTP agent and connection pool, reducing memory usage and improving performance.

Source

pub fn with_agent(agent: Arc<Agent>) -> Self

Create a SOAP client with a custom agent (for advanced use cases only)

Most applications should use SoapClient::get() instead for better resource efficiency. This method is provided for cases where custom timeout values or other HTTP client configuration is needed.

Source

pub fn new() -> Self

👎Deprecated since 0.1.0:

Use SoapClient::get() for shared resources

Create a new SOAP client with default configuration

DEPRECATED: Use SoapClient::get() instead for better resource efficiency. This method creates a separate HTTP agent instance, which wastes resources when multiple SOAP clients are used.

Source

pub fn call( &self, ip: &str, endpoint: &str, service_uri: &str, action: &str, payload: &str, ) -> Result<Element, SoapError>

Send a SOAP request and return the parsed response element

Source

pub fn subscribe( &self, ip: &str, port: u16, event_endpoint: &str, callback_url: &str, timeout_seconds: u32, ) -> Result<SubscriptionResponse, SoapError>

Subscribe to UPnP events for a specific service endpoint

§Arguments
  • ip - Device IP address
  • port - Device port (typically 1400)
  • event_endpoint - Event endpoint path (e.g., “MediaRenderer/AVTransport/Event”)
  • callback_url - URL where events should be sent
  • timeout_seconds - Requested subscription timeout in seconds
§Returns

A SubscriptionResponse containing the SID and actual timeout

Source

pub fn renew_subscription( &self, ip: &str, port: u16, event_endpoint: &str, sid: &str, timeout_seconds: u32, ) -> Result<u32, SoapError>

Renew an existing UPnP subscription

§Arguments
  • ip - Device IP address
  • port - Device port (typically 1400)
  • event_endpoint - Event endpoint path
  • sid - Subscription ID to renew
  • timeout_seconds - Requested renewal timeout in seconds
§Returns

The actual timeout granted by the device

Source

pub fn unsubscribe( &self, ip: &str, port: u16, event_endpoint: &str, sid: &str, ) -> Result<(), SoapError>

Unsubscribe from UPnP events

§Arguments
  • ip - Device IP address
  • port - Device port (typically 1400)
  • event_endpoint - Event endpoint path
  • sid - Subscription ID to cancel

Trait Implementations§

Source§

impl Clone for SoapClient

Source§

fn clone(&self) -> SoapClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SoapClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SoapClient

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.