1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//! Internal implementation detail of [`sonos-sdk`](https://crates.io/crates/sonos-sdk). Not intended for direct use.
//!
//! Sonos device discovery library
//!
//! This crate provides a simple API for discovering Sonos devices on a local network
//! using SSDP (Simple Service Discovery Protocol) and UPnP device descriptions.
//!
//! # Quick Start
//!
//! ```no_run
//! use sonos_discovery::get;
//!
//! // Discover all Sonos devices on the network
//! let devices = get();
//! for device in devices {
//! println!("Found {} at {}", device.name, device.ip_address);
//! }
//! ```
//!
//! # Iterator-based Discovery
//!
//! For more control, use the iterator API:
//!
//! ```no_run
//! use sonos_discovery::{get_iter, DeviceEvent};
//!
//! for event in get_iter() {
//! match event {
//! DeviceEvent::Found(device) => {
//! println!("Found: {}", device.name);
//! // Can break early if needed
//! }
//! }
//! }
//! ```
pub use DiscoveryIterator;
pub use ;
/// Information about a discovered Sonos device.
///
/// Contains all relevant metadata needed to identify and connect to a Sonos speaker.
/// Events emitted during device discovery.
///
/// Currently only supports device found events. Future versions may add additional
/// event types (e.g., device lost, device updated).
use Duration;
/// Discover all Sonos devices on the local network with a default 3-second timeout.
///
/// This is a convenience function that collects all discovered devices into a Vec.
/// For more control over the discovery process, use `get_iter()` instead.
///
/// # Examples
///
/// ```no_run
/// use sonos_discovery::get;
///
/// let devices = get();
/// for device in devices {
/// println!("Found: {} at {}", device.name, device.ip_address);
/// }
/// ```
/// Discover all Sonos devices on the local network with a custom timeout.
///
/// This function collects all discovered devices into a Vec. The timeout parameter
/// controls how long to wait for SSDP responses and HTTP requests.
///
/// # Arguments
///
/// * `timeout` - Maximum duration to wait for network operations
///
/// # Examples
///
/// ```no_run
/// use sonos_discovery::get_with_timeout;
/// use std::time::Duration;
///
/// let devices = get_with_timeout(Duration::from_secs(5));
/// for device in devices {
/// println!("Found: {} at {}", device.name, device.ip_address);
/// }
/// ```
/// Get an iterator for discovering Sonos devices with a default 3-second timeout.
///
/// This function returns an iterator that yields `DeviceEvent::Found` for each
/// discovered device. This allows for streaming processing and early termination.
///
/// # Examples
///
/// ```no_run
/// use sonos_discovery::{get_iter, DeviceEvent};
///
/// for event in get_iter() {
/// match event {
/// DeviceEvent::Found(device) => {
/// println!("Found: {} at {}", device.name, device.ip_address);
/// // Can break early if needed
/// break;
/// }
/// }
/// }
/// ```
/// Get an iterator for discovering Sonos devices with a custom timeout.
///
/// This function returns an iterator that yields `DeviceEvent::Found` for each
/// discovered device. The timeout parameter controls how long to wait for
/// SSDP responses and HTTP requests.
///
/// # Arguments
///
/// * `timeout` - Maximum duration to wait for network operations
///
/// # Examples
///
/// ```no_run
/// use sonos_discovery::{get_iter_with_timeout, DeviceEvent};
/// use std::time::Duration;
///
/// for event in get_iter_with_timeout(Duration::from_secs(5)) {
/// match event {
/// DeviceEvent::Found(device) => {
/// println!("Found: {} at {}", device.name, device.ip_address);
/// }
/// }
/// }
/// ```