File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,16 +8,18 @@ license = "MIT OR Apache-2.0"
88
99[features ]
1010default = [" server" , " client" ]
11- server = []
12- client = []
11+ decode = []
12+ encode = []
13+ server = [" decode" ]
14+ client = [" encode" ]
1315
1416[dependencies ]
1517# Async
1618tokio = { version = " *" , default-features = false }
1719tokio-util = { version = " *" , features = [" codec" ] }
1820
1921tokio-stream = " *"
20- futures-util = { version = " *" , default-features = false , features = [" sink" ]}
22+ futures-util = { version = " *" , default-features = false , features = [" sink" ] }
2123
2224bytes = " *"
2325uuid = " *"
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ pub enum AddressType {
3131 Other ( u8 ) ,
3232}
3333// https://github.com/zephry-works/wind/blob/main/crates/wind-tuic/SPEC.md#5-address-encoding
34- #[ cfg( feature = "server " ) ]
34+ #[ cfg( feature = "decode " ) ]
3535impl Decoder for AddressCodec {
3636 type Error = crate :: Error ;
3737 type Item = Address ;
@@ -102,7 +102,7 @@ impl Decoder for AddressCodec {
102102 }
103103}
104104
105- #[ cfg( feature = "client " ) ]
105+ #[ cfg( feature = "encode " ) ]
106106impl Encoder < Address > for AddressCodec {
107107 type Error = crate :: Error ;
108108
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ pub enum Command {
2929}
3030
3131// https://github.com/zephry-works/wind/blob/main/crates/wind-tuic/SPEC.md#3-command-specifications
32- #[ cfg( feature = "server " ) ]
32+ #[ cfg( feature = "decode " ) ]
3333impl Decoder for CommandCodec {
3434 type Error = crate :: Error ;
3535 type Item = Command ;
@@ -52,17 +52,13 @@ impl Decoder for CommandCodec {
5252 if src. len ( ) < 8 {
5353 return Ok ( None ) ;
5454 }
55- let assos_id = src. get_u16 ( ) ;
56- let pkt_id = src. get_u16 ( ) ;
57- let frag_total = src. get_u8 ( ) ;
58- let frag_id = src. get_u8 ( ) ;
59- let size = src. get_u16 ( ) ;
55+
6056 Ok ( Some ( Command :: Packet {
61- assos_id,
62- pkt_id,
63- frag_total,
64- frag_id,
65- size,
57+ assos_id : src . get_u16 ( ) ,
58+ pkt_id : src . get_u16 ( ) ,
59+ frag_total : src . get_u8 ( ) ,
60+ frag_id : src . get_u8 ( ) ,
61+ size : src . get_u16 ( ) ,
6662 } ) )
6763 }
6864 CommandType :: Dissociate => {
@@ -85,7 +81,7 @@ impl Decoder for CommandCodec {
8581 }
8682}
8783
88- #[ cfg( feature = "client " ) ]
84+ #[ cfg( feature = "encode " ) ]
8985impl Encoder < Command > for CommandCodec {
9086 type Error = crate :: Error ;
9187
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ impl Header {
3636 }
3737}
3838
39- #[ cfg( feature = "server " ) ]
39+ #[ cfg( feature = "decode " ) ]
4040impl Decoder for HeaderCodec {
4141 type Error = crate :: Error ;
4242 type Item = Header ;
@@ -63,7 +63,7 @@ impl Decoder for HeaderCodec {
6363 }
6464}
6565
66- #[ cfg( feature = "client " ) ]
66+ #[ cfg( feature = "encode " ) ]
6767impl Encoder < Header > for HeaderCodec {
6868 type Error = crate :: Error ;
6969
You can’t perform that action at this time.
0 commit comments