Skip to content

Commit 6b6d115

Browse files
djcRalith
authored andcommitted
book: order set-up-connection code in top-down order
1 parent a196f7c commit 6b6d115

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

docs/book/src/bin/set-up-connection.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ use quinn::{Endpoint, ServerConfig};
22
use std::error::Error;
33
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
44

5-
const SERVER_NAME: &str = "localhost";
6-
const LOCALHOST_V4: IpAddr = IpAddr::V4(Ipv4Addr::LOCALHOST);
7-
const CLIENT_ADDR: SocketAddr = SocketAddr::new(LOCALHOST_V4, 5000);
8-
const SERVER_ADDR: SocketAddr = SocketAddr::new(LOCALHOST_V4, 5001);
5+
fn main() {}
96

107
#[allow(dead_code, unused_variables)] // Included in `set-up-connection.md`
118
async fn server(config: ServerConfig) -> Result<(), Box<dyn Error>> {
@@ -35,4 +32,7 @@ async fn client() -> Result<(), Box<dyn Error>> {
3532
Ok(())
3633
}
3734

38-
fn main() {}
35+
const SERVER_NAME: &str = "localhost";
36+
const LOCALHOST_V4: IpAddr = IpAddr::V4(Ipv4Addr::LOCALHOST);
37+
const CLIENT_ADDR: SocketAddr = SocketAddr::new(LOCALHOST_V4, 5000);
38+
const SERVER_ADDR: SocketAddr = SocketAddr::new(LOCALHOST_V4, 5001);

docs/book/src/quinn/set-up-connection.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ It all starts with the [Endpoint][Endpoint] struct, this is the entry point of t
1212
Let's start by defining some constants.
1313

1414
```rust
15-
{{#include ../bin/set-up-connection.rs:5:8}}
15+
{{#include ../bin/set-up-connection.rs:35:38}}
1616
```
1717

1818
**Server**
@@ -22,7 +22,7 @@ The [server()][server] method, which can be used for this, returns the `Endpoint
2222
`Endpoint` is used to start outgoing connections and accept incoming connections.
2323

2424
```rust
25-
{{#include ../bin/set-up-connection.rs:11:23}}
25+
{{#include ../bin/set-up-connection.rs:8:20}}
2626
```
2727

2828
**Client**
@@ -32,7 +32,7 @@ The client needs to connect to the server using the [connect(server_name)][conne
3232
The `SERVER_NAME` argument is the DNS name, matching the certificate configured in the server.
3333

3434
```rust
35-
{{#include ../bin/set-up-connection.rs:26:36}}
35+
{{#include ../bin/set-up-connection.rs:23:33}}
3636
```
3737

3838
<br><hr>

0 commit comments

Comments
 (0)