Skip to content

Commit c676720

Browse files
committed
Update docstring
1 parent c662253 commit c676720

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/utils_internal.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,39 @@ pub async fn build_tcp_stream(
200200
Ok(StreamHandle::from_stream(stream))
201201
}
202202

203+
/// A helper method that uses the `btleplug` and `tokio` crates to build a BLE stream
204+
/// that is compatible with the `StreamApi` API. This requires that the stream
205+
/// implements `AsyncReadExt + AsyncWriteExt` traits.
206+
///
207+
/// This method is intended to be used to create a `DuplexStream` instance, which is
208+
/// then passed into the `StreamApi::connect` method.
209+
///
210+
/// # Arguments
211+
///
212+
/// * `ble_id` - Name or MAC address of a BLE device
213+
///
214+
/// # Returns
215+
///
216+
/// Returns a result that resolves to a `tokio::io::DuplexStream` instance, or
217+
/// an error if the stream could not be created.
218+
///
219+
/// # Examples
220+
///
221+
/// ```
222+
/// // Connect to a radio, identified by its MAC address
223+
/// let duplex_stream = utils::build_ble_stream(BleId::from_mac_address("E3:44:4E:18:F7:A4").await?;
224+
/// let decoded_listener = stream_api.connect(duplex_stream).await;
225+
/// ```
226+
///
227+
/// # Errors
228+
///
229+
/// Will return an instance of `Error` in the event that the radio refuses the connection, it
230+
/// cannot be found or if the specified address is invalid.
231+
///
232+
/// # Panics
233+
///
234+
/// None
235+
///
203236
#[cfg(feature = "bluetooth-le")]
204237
pub async fn build_ble_stream(
205238
ble_id: &crate::connections::ble_handler::BleId,

0 commit comments

Comments
 (0)