1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*! # Synchronous methods
This is just provided so you can open a `std::net::TcpStream` connection
And so you have a `register()` method that works with just `std::io::Write`
You probably would want to use the async `connect/register` methods from the crate root.
*/
use crate::;
use Write;
use TcpStream;
/**
Write the provided `UserConfig` to the ***sync*** writer
# Example
```rust
# use twitchchat::{UserConfig, sync::*};
let config = UserConfig::builder().anonymous().build().unwrap();
let mut writer = vec![];
register(&config, &mut writer).unwrap();
assert_eq!(
std::str::from_utf8(&writer).unwrap(),
"PASS justinfan1234\r\nNICK justinfan1234\r\n"
);
```
*/
Sized + Write>
/**
Write the provided `name` and `token` to the ***sync*** writer
# Example
```rust
# use twitchchat::sync::*;
let (name, token) = ("justinfan1234", "justinfan1234");
let mut writer = vec![];
register_easy(&name, &token, &mut writer).unwrap();
assert_eq!(
std::str::from_utf8(&writer).unwrap(),
"CAP REQ :twitch.tv/membership\r\n\
CAP REQ :twitch.tv/tags\r\n\
CAP REQ :twitch.tv/commands\r\n\
PASS justinfan1234\r\n\
NICK justinfan1234\r\n"
);
```
*/
Sized + Write>
/**
Opens a ***sync*** TCP connection using the provided `UserConfig`
# Note
This doesn't support TLS because ***TlsStream*** isn't clonable.
Use the [async version][async] if you want a TLS wrapped connection
# Example
```rust,no_run
# use twitchchat::{sync::*, UserConfig};
let user_config = UserConfig::builder().anonymous().build().unwrap();
let conn = connect(&user_config).unwrap();
```
[async]: ../fn.connect.html
*/
/**
Opens a ***sync*** TCP connection using the provided `name` and `token`
This enables all of the [Capabilities]
# Note
This doesn't support TLS because TlsStream isn't clonable.
Use the [async version][async] if you want a TLS wrapped connection
# Example
```rust,no_run
# use twitchchat::{sync::*, ANONYMOUS_LOGIN};
let (nick, pass) = ANONYMOUS_LOGIN;
let conn = connect_easy(&nick, &pass).unwrap();
```
[Capabilities]: ../enum.Capability.html
[async]: ../fn.connect_easy.html
*/
// TODO: add a SyncClient if we want to keep this
pub use crate Encoder;