We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5feee48 commit d747e67Copy full SHA for d747e67
core/src/transport/timeout.rs
@@ -22,7 +22,20 @@
22
//!
23
//! The connection setup includes all protocol upgrades applied on the
24
//! underlying `Transport`.
25
-// TODO: add example
+//!
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
+//! ```
39
40
use std::{
41
error, fmt, io,
0 commit comments