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
impl SoapClient
Sourcepub fn get() -> &'static Self
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.
Sourcepub fn with_agent(agent: Arc<Agent>) -> Self
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.
Sourcepub fn new() -> Self
👎Deprecated since 0.1.0: Use SoapClient::get() for shared resources
pub fn new() -> Self
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.
Sourcepub fn call(
&self,
ip: &str,
endpoint: &str,
service_uri: &str,
action: &str,
payload: &str,
) -> Result<Element, SoapError>
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
Sourcepub fn subscribe(
&self,
ip: &str,
port: u16,
event_endpoint: &str,
callback_url: &str,
timeout_seconds: u32,
) -> Result<SubscriptionResponse, SoapError>
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 addressport- Device port (typically 1400)event_endpoint- Event endpoint path (e.g., “MediaRenderer/AVTransport/Event”)callback_url- URL where events should be senttimeout_seconds- Requested subscription timeout in seconds
§Returns
A SubscriptionResponse containing the SID and actual timeout
Trait Implementations§
Source§impl Clone for SoapClient
impl Clone for SoapClient
Source§fn clone(&self) -> SoapClient
fn clone(&self) -> SoapClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more