Skip to content

Commit d747e67

Browse files
committed
core: Add doc example to TransportTimeout
1 parent 5feee48 commit d747e67

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

core/src/transport/timeout.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,20 @@
2222
//!
2323
//! The connection setup includes all protocol upgrades applied on the
2424
//! underlying `Transport`.
25-
// TODO: add example
25+
//!
26+
//! # Example
27+
//!
28+
//! ```no_run
29+
//! use libp2p_core::{transport::MemoryTransport, Transport as _};
30+
//! use libp2p_core::transport::{timeout::TransportTimeout, ListenerId};
31+
//! use std::time::Duration;
32+
//!
33+
//! let base = MemoryTransport::default();
34+
//! let mut timeout = TransportTimeout::new(base, Duration::from_secs(1));
35+
//!
36+
//! // Listen and dial as usual; the setup will be subject to timeouts.
37+
//! let _ = timeout.listen_on(ListenerId::next(), "/memory/0".parse().unwrap());
38+
//! ```
2639
2740
use std::{
2841
error, fmt, io,

0 commit comments

Comments
 (0)