Skip to content

Commit d153d3a

Browse files
authored
Internal reorganization (#65)
* Thread utility. Added event thread * Renamed util module to thread module * Added util module for thread and encoding * Enable README examples compilation & testing * Move network files into network module.
1 parent f27149c commit d153d3a

32 files changed

+1096
-990
lines changed

.rustfmt.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,3 @@ trailing_semicolon = false
66
use_field_init_shorthand = true
77
use_try_shorthand = true
88
where_single_line = true
9-
ignore = [
10-
"examples/readme_echo_client.rs",
11-
"examples/readme_echo_server.rs",
12-
]

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ chrono = "0.4.19"
4242
test-case = "1.1.0"
4343
rand = "0.8.3"
4444
httparse = "1.3.5"
45+
doc-comment = "0.3"
4546

4647
# Only for tests
4748
#![cfg_attr(test, feature(proc_macro))]

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@ You could change the transport of your application in literally one line.
6565

6666
## Getting started
6767
Add to your `Cargo.toml` (all the transports included by default):
68-
```
68+
```toml
69+
[dependencies]
6970
message-io = "0.11"
7071
```
7172
If you **only** want to use a subset of the available transport battery,
7273
you can select them by their associated features `tcp`, `udp`, and `websocket`.
7374
For example, in order to include only *TCP* and *UDP*, add to your `Cargo.toml`:
74-
```
75+
```toml
76+
[dependencies]
7577
message-io = { version = "0.11", default-features = false, features = ["tcp", "udp"] }
7678
```
7779

@@ -99,7 +101,7 @@ to them.
99101
It is capable to manage several client connections and listen from 3 differents protocols
100102
at the same time.
101103

102-
```rust
104+
```rust,no_run
103105
use message_io::network::{Network, NetEvent, Transport};
104106
105107
fn main() {
@@ -130,7 +132,7 @@ It sends a message each second to the server and listen its echo response.
130132
Changing the `Transport::FramedTcp` to `Udp` or `Ws` will change the underlying transport used.
131133
Also, you can create the number of connections you want at the same time, without any extra thread.
132134

133-
```rust
135+
```rust,no_run
134136
use message_io::network::{Network, NetEvent, Transport};
135137
136138
enum Event {
@@ -169,11 +171,11 @@ Clone the repository and test the *Ping Pong* example
169171
(similar to the *echo* example but more vitaminized).
170172

171173
Run the server:
172-
```
174+
```sh
173175
cargo run --example ping-pong server tcp 3456
174176
```
175177
Run the client:
176-
```
178+
```sh
177179
cargo run --example ping-pong client tcp 127.0.0.1:3456
178180
```
179181

examples/readme_echo_client.rs

Lines changed: 0 additions & 31 deletions
This file was deleted.

examples/readme_echo_server.rs

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/adapter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::remote_addr::{RemoteAddr};
1+
use crate::network::{RemoteAddr};
22

33
use mio::event::{Source};
44

src/adapters/framed_tcp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use crate::adapter::{
22
Resource, Remote, Local, Adapter, SendStatus, AcceptedType, ReadStatus, ConnectionInfo,
33
ListeningInfo,
44
};
5-
use crate::remote_addr::{RemoteAddr};
6-
use crate::encoding::{self, Decoder, MAX_ENCODED_SIZE};
5+
use crate::network::{RemoteAddr};
6+
use crate::util::encoding::{self, Decoder, MAX_ENCODED_SIZE};
77

88
use mio::net::{TcpListener, TcpStream};
99
use mio::event::{Source};

src/adapters/tcp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::adapter::{
22
Resource, Remote, Local, Adapter, SendStatus, AcceptedType, ReadStatus, ConnectionInfo,
33
ListeningInfo,
44
};
5-
use crate::remote_addr::{RemoteAddr};
5+
use crate::network::{RemoteAddr};
66

77
use mio::net::{TcpListener, TcpStream};
88
use mio::event::{Source};

src/adapters/template.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::adapter::{
44
Resource, Remote, Local, Adapter, SendStatus, AcceptedType, ReadStatus, ConnectionInfo,
55
ListeningInfo,
66
};
7-
use crate::remote_addr::{RemoteAddr};
7+
use crate::network::{RemoteAddr};
88

99
use mio::event::{Source};
1010

0 commit comments

Comments
 (0)