@@ -757,7 +757,7 @@ impl Connection {
757757 self . receiving_ecn ,
758758 & mut SentFrames :: default ( ) ,
759759 & mut self . spaces [ space_id] ,
760- & mut buf,
760+ & mut buf. 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 buf, max_frame_size)
777+ reason. encode ( & mut buf. 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 buf, max_frame_size)
784+ . encode ( & mut buf. 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 buf, max_frame_size) ,
792+ . encode ( & mut buf. datagram_mut ( ) , max_frame_size) ,
793793 _ => unreachable ! (
794794 "tried to make a close packet when the connection wasn't closed"
795795 ) ,
@@ -817,8 +817,8 @@ impl Connection {
817817 // above.
818818 let mut builder = builder_storage. take ( ) . unwrap ( ) ;
819819 trace ! ( "PATH_RESPONSE {:08x} (off-path)" , token) ;
820- buf. write ( frame:: FrameType :: PATH_RESPONSE ) ;
821- buf. write ( token) ;
820+ buf. datagram_mut ( ) . write ( frame:: FrameType :: PATH_RESPONSE ) ;
821+ buf. datagram_mut ( ) . write ( token) ;
822822 self . stats . frame_tx . path_response += 1 ;
823823 builder. pad_to ( MIN_INITIAL_SIZE ) ;
824824 builder. finish_and_track (
@@ -844,7 +844,7 @@ impl Connection {
844844 let sent = self . populate_packet (
845845 now,
846846 space_id,
847- & mut buf,
847+ & mut buf. datagram_mut ( ) ,
848848 builder. max_size ,
849849 builder. exact_number ,
850850 ) ;
@@ -908,12 +908,12 @@ impl Connection {
908908 PacketBuilder :: new ( now, space_id, self . rem_cids . active ( ) , & mut buf, true , self ) ?;
909909
910910 // We implement MTU probes as ping packets padded up to the probe size
911- buf. write ( frame:: FrameType :: PING ) ;
911+ buf. datagram_mut ( ) . write ( frame:: FrameType :: PING ) ;
912912 self . stats . frame_tx . ping += 1 ;
913913
914914 // If supported by the peer, we want no delays to the probe's ACK
915915 if self . peer_supports_ack_frequency ( ) {
916- buf. write ( frame:: FrameType :: IMMEDIATE_ACK ) ;
916+ buf. datagram_mut ( ) . write ( frame:: FrameType :: IMMEDIATE_ACK ) ;
917917 self . stats . frame_tx . immediate_ack += 1 ;
918918 }
919919
@@ -986,8 +986,8 @@ impl Connection {
986986 debug_assert_eq ! ( buf. datagram_start_offset( ) , 0 ) ;
987987 let mut builder = PacketBuilder :: new ( now, SpaceId :: Data , * prev_cid, buf, false , self ) ?;
988988 trace ! ( "validating previous path with PATH_CHALLENGE {:08x}" , token) ;
989- buf. write ( frame:: FrameType :: PATH_CHALLENGE ) ;
990- buf. write ( token) ;
989+ buf. datagram_mut ( ) . write ( frame:: FrameType :: PATH_CHALLENGE ) ;
990+ buf. datagram_mut ( ) . write ( token) ;
991991 self . stats . frame_tx . path_challenge += 1 ;
992992
993993 // An endpoint MUST expand datagrams that contain a PATH_CHALLENGE frame
@@ -3975,6 +3975,12 @@ impl BufLen for Vec<u8> {
39753975 }
39763976}
39773977
3978+ impl BufLen for bytes:: buf:: Limit < & mut Vec < u8 > > {
3979+ fn len ( & self ) -> usize {
3980+ self . get_ref ( ) . len ( )
3981+ }
3982+ }
3983+
39783984#[ cfg( test) ]
39793985mod tests {
39803986 use super :: * ;
0 commit comments