Skip to content

Commit 962e3ae

Browse files
author
rusty
committed
Add documentation for stop_on method
1 parent a166193 commit 962e3ae

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/server.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,24 @@ where
322322
&self.state
323323
}
324324

325+
/// Stops the server when given `stop_token` completes.
326+
///
327+
/// # Example
328+
///
329+
/// ```rust
330+
/// use tide::cancellation::StopSource;
331+
///
332+
/// let mut app = tide::new();
333+
///
334+
/// let stop_source = StopSource::new();
335+
///
336+
/// app.stop_on(stop_source.token());
337+
///
338+
/// // Runs server...
339+
///
340+
/// // When something happens
341+
/// drop(stop_source);
342+
/// ```
325343
pub fn stop_on(&mut self, stop_token: StopToken) -> &mut Self {
326344
self.stop_token = stop_token;
327345
self

0 commit comments

Comments
 (0)