Skip to main content

MockIgdServer

Struct MockIgdServer 

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

A mock UPnP IGD server for testing.

Implementations§

Source§

impl MockIgdServer

Source

pub async fn start() -> Result<Self>

Start a new mock IGD server on a random available port.

Source

pub fn builder() -> MockIgdServerBuilder

Create a builder for configuring the server.

Source

pub fn url(&self) -> String

Get the URL of the HTTP server (for SOAP requests).

Source

pub fn control_url(&self) -> String

Get the control URL for SOAP actions.

Source

pub fn description_url(&self) -> String

Get the device description URL.

Source

pub fn http_addr(&self) -> SocketAddr

Get the HTTP server address.

Source

pub fn ssdp_addr(&self) -> Option<SocketAddr>

Get the SSDP server address (if enabled).

Source

pub async fn mock( &self, action: impl Into<Action>, responder: impl Into<Responder>, )

Register a mock for the given action.

Source

pub async fn mock_with_priority( &self, action: impl Into<Action>, responder: impl Into<Responder>, priority: u32, )

Register a mock with a specific priority (higher = checked first).

Source

pub async fn mock_with_times( &self, action: impl Into<Action>, responder: impl Into<Responder>, times: u32, )

Register a mock that only matches a limited number of times.

Source

pub async fn clear_mocks(&self)

Clear all registered mocks.

Source

pub async fn received_requests(&self) -> Vec<ReceivedRequest>

Get all received requests.

Returns a list of all SOAP requests received by the server. Useful for verifying that expected requests were made.

§Example
let requests = server.received_requests().await;
assert_eq!(requests.len(), 1);
assert_eq!(requests[0].action_name, "GetExternalIPAddress");
Source

pub async fn clear_received_requests(&self)

Clear all received requests.

Source

pub async fn received_ssdp_requests(&self) -> Vec<ReceivedSsdpRequest>

Get all received SSDP requests (M-SEARCH).

Returns a list of all SSDP M-SEARCH requests received by the server. Useful for verifying device discovery behavior.

§Example
let requests = server.received_ssdp_requests().await;
assert_eq!(requests.len(), 1);
assert_eq!(requests[0].search_target, "ssdp:all");
Source

pub async fn clear_received_ssdp_requests(&self)

Clear all received SSDP requests.

Source

pub fn shutdown(self)

Shutdown the server.

Trait Implementations§

Source§

impl Drop for MockIgdServer

Source§

fn drop(&mut self)

Executes the destructor for this 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,