@@ -757,7 +757,7 @@ impl Connection {
757757 self . receiving_ecn ,
758758 & mut SentFrames :: default ( ) ,
759759 & mut self . spaces [ space_id] ,
760- & mut transmit,
760+ & mut transmit. datagram_mut ( ) ,
761761 & mut self . stats ,
762762 ) ;
763763 }
@@ -774,22 +774,22 @@ impl Connection {
774774 match self . state {
775775 State :: Closed ( state:: Closed { ref reason } ) => {
776776 if space_id == SpaceId :: Data || reason. is_transport_layer ( ) {
777- reason. encode ( & mut transmit, max_frame_size)
777+ reason. encode ( & mut transmit. datagram_mut ( ) , max_frame_size)
778778 } else {
779779 frame:: ConnectionClose {
780780 error_code : TransportErrorCode :: APPLICATION_ERROR ,
781781 frame_type : None ,
782782 reason : Bytes :: new ( ) ,
783783 }
784- . encode ( & mut transmit, max_frame_size)
784+ . encode ( & mut transmit. datagram_mut ( ) , max_frame_size)
785785 }
786786 }
787787 State :: Draining => frame:: ConnectionClose {
788788 error_code : TransportErrorCode :: NO_ERROR ,
789789 frame_type : None ,
790790 reason : Bytes :: new ( ) ,
791791 }
792- . encode ( & mut transmit, max_frame_size) ,
792+ . encode ( & mut transmit. datagram_mut ( ) , max_frame_size) ,
793793 _ => unreachable ! (
794794 "tried to make a close packet when the connection wasn't closed"
795795 ) ,
@@ -817,8 +817,10 @@ impl Connection {
817817 // above.
818818 let mut builder = builder_storage. take ( ) . unwrap ( ) ;
819819 trace ! ( "PATH_RESPONSE {:08x} (off-path)" , token) ;
820- transmit. write ( frame:: FrameType :: PATH_RESPONSE ) ;
821- transmit. write ( token) ;
820+ transmit
821+ . datagram_mut ( )
822+ . write ( frame:: FrameType :: PATH_RESPONSE ) ;
823+ transmit. datagram_mut ( ) . write ( token) ;
822824 self . stats . frame_tx . path_response += 1 ;
823825 builder. pad_to ( MIN_INITIAL_SIZE ) ;
824826 builder. finish_and_track (
@@ -844,7 +846,7 @@ impl Connection {
844846 let sent = self . populate_packet (
845847 now,
846848 space_id,
847- & mut transmit,
849+ & mut transmit. datagram_mut ( ) ,
848850 builder. max_size ,
849851 builder. exact_number ,
850852 ) ;
@@ -914,12 +916,14 @@ impl Connection {
914916 ) ?;
915917
916918 // We implement MTU probes as ping packets padded up to the probe size
917- transmit. write ( frame:: FrameType :: PING ) ;
919+ transmit. datagram_mut ( ) . write ( frame:: FrameType :: PING ) ;
918920 self . stats . frame_tx . ping += 1 ;
919921
920922 // If supported by the peer, we want no delays to the probe's ACK
921923 if self . peer_supports_ack_frequency ( ) {
922- transmit. write ( frame:: FrameType :: IMMEDIATE_ACK ) ;
924+ transmit
925+ . datagram_mut ( )
926+ . write ( frame:: FrameType :: IMMEDIATE_ACK ) ;
923927 self . stats . frame_tx . immediate_ack += 1 ;
924928 }
925929
@@ -996,8 +1000,8 @@ impl Connection {
9961000 debug_assert_eq ! ( buf. datagram_start_offset( ) , 0 ) ;
9971001 let mut builder = PacketBuilder :: new ( now, SpaceId :: Data , * prev_cid, buf, false , self ) ?;
9981002 trace ! ( "validating previous path with PATH_CHALLENGE {:08x}" , token) ;
999- buf. write ( frame:: FrameType :: PATH_CHALLENGE ) ;
1000- buf. write ( token) ;
1003+ buf. datagram_mut ( ) . write ( frame:: FrameType :: PATH_CHALLENGE ) ;
1004+ buf. datagram_mut ( ) . write ( token) ;
10011005 self . stats . frame_tx . path_challenge += 1 ;
10021006
10031007 // An endpoint MUST expand datagrams that contain a PATH_CHALLENGE frame
@@ -3985,6 +3989,12 @@ impl BufLen for Vec<u8> {
39853989 }
39863990}
39873991
3992+ impl BufLen for bytes:: buf:: Limit < & mut Vec < u8 > > {
3993+ fn len ( & self ) -> usize {
3994+ self . get_ref ( ) . len ( )
3995+ }
3996+ }
3997+
39883998#[ cfg( test) ]
39893999mod tests {
39904000 use super :: * ;
0 commit comments