11extern crate bytes;
22
3- use crate :: result :: { RSocketResult } ;
4- use crate :: errors :: { RSocketError } ;
3+ use crate :: errors :: RSocketError ;
4+ use crate :: result :: RSocketResult ;
55use bytes:: { BigEndian , BufMut , ByteOrder , Bytes , BytesMut } ;
66
77mod cancel;
@@ -19,9 +19,10 @@ mod resume;
1919mod resume_ok;
2020mod setup;
2121mod utils;
22+ mod version;
2223
2324pub use cancel:: Cancel ;
24- pub use error:: { Error } ;
25+ pub use error:: Error ;
2526pub use keepalive:: Keepalive ;
2627pub use lease:: Lease ;
2728pub use metadata_push:: MetadataPush ;
@@ -35,6 +36,7 @@ pub use resume::Resume;
3536pub use resume_ok:: ResumeOK ;
3637pub use setup:: { Setup , SetupBuilder } ;
3738pub use utils:: * ;
39+ pub use version:: Version ;
3840
3941pub const FLAG_NEXT : u16 = 0x01 << 5 ;
4042pub const FLAG_COMPLETE : u16 = 0x01 << 6 ;
@@ -122,7 +124,7 @@ impl Writeable for Frame {
122124 Body :: Error ( v) => v. write_to ( bf) ,
123125 Body :: Cancel ( ) => ( ) ,
124126 Body :: ResumeOK ( v) => v. write_to ( bf) ,
125- _ => unimplemented ! ( ) ,
127+ Body :: Resume ( v ) => v . write_to ( bf ) ,
126128 }
127129 }
128130
@@ -143,7 +145,7 @@ impl Writeable for Frame {
143145 Body :: Cancel ( ) => 0 ,
144146 Body :: Error ( v) => v. len ( ) ,
145147 Body :: ResumeOK ( v) => v. len ( ) ,
146- _ => unimplemented ! ( ) ,
148+ Body :: Resume ( v ) => v . len ( ) ,
147149 }
148150 }
149151}
@@ -165,29 +167,30 @@ impl Frame {
165167 b. advance ( 2 ) ;
166168 let ( flag, kind) = ( n & 0x03FF , ( n & 0xFC00 ) >> 10 ) ;
167169 let body = match kind {
168- TYPE_SETUP => Setup :: decode ( flag, b) . map ( |it|Body :: Setup ( it) ) ,
169- TYPE_REQUEST_RESPONSE =>RequestResponse :: decode ( flag, b) . map ( |it|Body :: RequestResponse ( it) ) ,
170- TYPE_REQUEST_STREAM => RequestStream :: decode ( flag, b) . map ( |it|Body :: RequestStream ( it) ) ,
171- TYPE_REQUEST_CHANNEL => RequestChannel :: decode ( flag, b) . map ( |it|Body :: RequestChannel ( it) ) ,
172- TYPE_REQUEST_FNF => RequestFNF :: decode ( flag, b) . map ( |it|Body :: RequestFNF ( it) ) ,
173- TYPE_REQUEST_N => RequestN :: decode ( flag, b) . map ( |it|Body :: RequestN ( it) ) ,
174- TYPE_METADATA_PUSH => MetadataPush :: decode ( flag, b) . map ( |it|Body :: MetadataPush ( it) ) ,
175- TYPE_KEEPALIVE => Keepalive :: decode ( flag, b) . map ( |it|Body :: Keepalive ( it) ) ,
176- TYPE_PAYLOAD => Payload :: decode ( flag, b) . map ( |it|Body :: Payload ( it) ) ,
177- TYPE_LEASE => Lease :: decode ( flag, b) . map ( |it|Body :: Lease ( it) ) ,
170+ TYPE_SETUP => Setup :: decode ( flag, b) . map ( |it| Body :: Setup ( it) ) ,
171+ TYPE_REQUEST_RESPONSE => RequestResponse :: decode ( flag, b) . map ( |it| Body :: RequestResponse ( it) ) ,
172+ TYPE_REQUEST_STREAM => RequestStream :: decode ( flag, b) . map ( |it| Body :: RequestStream ( it) ) ,
173+ TYPE_REQUEST_CHANNEL => RequestChannel :: decode ( flag, b) . map ( |it| Body :: RequestChannel ( it) ) ,
174+ TYPE_REQUEST_FNF => RequestFNF :: decode ( flag, b) . map ( |it| Body :: RequestFNF ( it) ) ,
175+ TYPE_REQUEST_N => RequestN :: decode ( flag, b) . map ( |it| Body :: RequestN ( it) ) ,
176+ TYPE_METADATA_PUSH => MetadataPush :: decode ( flag, b) . map ( |it| Body :: MetadataPush ( it) ) ,
177+ TYPE_KEEPALIVE => Keepalive :: decode ( flag, b) . map ( |it| Body :: Keepalive ( it) ) ,
178+ TYPE_PAYLOAD => Payload :: decode ( flag, b) . map ( |it| Body :: Payload ( it) ) ,
179+ TYPE_LEASE => Lease :: decode ( flag, b) . map ( |it| Body :: Lease ( it) ) ,
178180 TYPE_CANCEL => Ok ( Body :: Cancel ( ) ) ,
179- TYPE_ERROR => Error :: decode ( flag, b) . map ( |it|Body :: Error ( it) ) ,
180- TYPE_RESUME_OK => ResumeOK :: decode ( flag, b) . map ( |it|Body :: ResumeOK ( it) ) ,
181+ TYPE_ERROR => Error :: decode ( flag, b) . map ( |it| Body :: Error ( it) ) ,
182+ TYPE_RESUME_OK => ResumeOK :: decode ( flag, b) . map ( |it| Body :: ResumeOK ( it) ) ,
183+ TYPE_RESUME => Resume :: decode ( flag, b) . map ( |it| Body :: Resume ( it) ) ,
181184 _ => Err ( RSocketError :: from ( "illegal frame type" ) ) ,
182185 } ;
183- body. map ( |it|Frame :: new ( sid, it, flag) )
186+ body. map ( |it| Frame :: new ( sid, it, flag) )
184187 }
185188
186189 pub fn get_body ( & self ) -> & Body {
187190 & self . body
188191 }
189192
190- pub fn get_frame_type ( & self ) -> u16 {
193+ pub fn get_frame_type ( & self ) -> u16 {
191194 to_frame_type ( & self . body )
192195 }
193196
@@ -199,12 +202,12 @@ impl Frame {
199202 self . stream_id . clone ( )
200203 }
201204
202- pub fn has_next ( & self ) -> bool {
205+ pub fn has_next ( & self ) -> bool {
203206 self . flag & FLAG_NEXT != 0
204207 }
205208
206- pub fn has_complete ( & self ) -> bool {
207- self . flag & FLAG_COMPLETE != 0
209+ pub fn has_complete ( & self ) -> bool {
210+ self . flag & FLAG_COMPLETE != 0
208211 }
209212}
210213
0 commit comments