1
1
use std:: {
2
2
convert:: TryFrom ,
3
- marker:: PhantomData ,
4
3
sync:: { Arc , RwLock , RwLockReadGuard , RwLockWriteGuard } ,
5
4
task:: { Context , Poll } ,
6
5
} ;
79
78
pub ( super ) shared : SharedStateRef ,
80
79
conn : C ,
81
80
control_send : C :: SendStream ,
82
- control_recv : Option < FrameStream < C :: RecvStream > > ,
83
- decoder_recv : Option < AcceptedRecvStream < C :: RecvStream > > ,
84
- encoder_recv : Option < AcceptedRecvStream < C :: RecvStream > > ,
81
+ control_recv : Option < FrameStream < C :: RecvStream , B > > ,
82
+ decoder_recv : Option < AcceptedRecvStream < C :: RecvStream , B > > ,
83
+ encoder_recv : Option < AcceptedRecvStream < C :: RecvStream , B > > ,
85
84
pending_recv_streams : Vec < AcceptRecvStream < C :: RecvStream > > ,
86
85
// The id of the last stream received by this connection:
87
86
// request and push stream for server and clients respectively.
@@ -307,21 +306,23 @@ where
307
306
}
308
307
309
308
pub struct RequestStream < S , B > {
310
- pub ( super ) stream : S ,
309
+ pub ( super ) stream : FrameStream < S , B > ,
311
310
pub ( super ) trailers : Option < Bytes > ,
312
311
pub ( super ) conn_state : SharedStateRef ,
313
312
pub ( super ) max_field_section_size : u64 ,
314
- _phantom_buffer : PhantomData < B > ,
315
313
}
316
314
317
315
impl < S , B > RequestStream < S , B > {
318
- pub fn new ( stream : S , max_field_section_size : u64 , conn_state : SharedStateRef ) -> Self {
316
+ pub fn new (
317
+ stream : FrameStream < S , B > ,
318
+ max_field_section_size : u64 ,
319
+ conn_state : SharedStateRef ,
320
+ ) -> Self {
319
321
Self {
320
322
stream,
321
323
conn_state,
322
324
max_field_section_size,
323
325
trailers : None ,
324
- _phantom_buffer : PhantomData ,
325
326
}
326
327
}
327
328
}
@@ -332,7 +333,7 @@ impl<S, B> ConnectionState for RequestStream<S, B> {
332
333
}
333
334
}
334
335
335
- impl < S , B > RequestStream < FrameStream < S > , B >
336
+ impl < S , B > RequestStream < S , B >
336
337
where
337
338
S : quic:: RecvStream ,
338
339
{
@@ -406,9 +407,9 @@ where
406
407
}
407
408
}
408
409
409
- impl < S , B > RequestStream < FrameStream < S > , B >
410
+ impl < S , B > RequestStream < S , B >
410
411
where
411
- S : quic:: SendStream < B > + quic :: RecvStream ,
412
+ S : quic:: SendStream < B > ,
412
413
B : Buf ,
413
414
{
414
415
/// Send some data on the response body.
@@ -449,3 +450,33 @@ where
449
450
. map_err ( |e| self . maybe_conn_err ( e) )
450
451
}
451
452
}
453
+
454
+ impl < S , B > RequestStream < S , B >
455
+ where
456
+ S : quic:: BidiStream < B > ,
457
+ B : Buf ,
458
+ {
459
+ pub ( crate ) fn split (
460
+ self ,
461
+ ) -> (
462
+ RequestStream < S :: SendStream , B > ,
463
+ RequestStream < S :: RecvStream , B > ,
464
+ ) {
465
+ let ( send, recv) = self . stream . split ( ) ;
466
+
467
+ (
468
+ RequestStream {
469
+ stream : send,
470
+ trailers : None ,
471
+ conn_state : self . conn_state . clone ( ) ,
472
+ max_field_section_size : 0 ,
473
+ } ,
474
+ RequestStream {
475
+ stream : recv,
476
+ trailers : self . trailers ,
477
+ conn_state : self . conn_state ,
478
+ max_field_section_size : self . max_field_section_size ,
479
+ } ,
480
+ )
481
+ }
482
+ }
0 commit comments