@@ -757,7 +757,7 @@ impl Connection {
757
757
self . receiving_ecn ,
758
758
& mut SentFrames :: default ( ) ,
759
759
& mut self . spaces [ space_id] ,
760
- & mut buf,
760
+ & mut buf. datagram_mut ( ) ,
761
761
& mut self . stats ,
762
762
) ;
763
763
}
@@ -774,22 +774,22 @@ impl Connection {
774
774
match self . state {
775
775
State :: Closed ( state:: Closed { ref reason } ) => {
776
776
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)
778
778
} else {
779
779
frame:: ConnectionClose {
780
780
error_code : TransportErrorCode :: APPLICATION_ERROR ,
781
781
frame_type : None ,
782
782
reason : Bytes :: new ( ) ,
783
783
}
784
- . encode ( & mut buf, max_frame_size)
784
+ . encode ( & mut buf. datagram_mut ( ) , max_frame_size)
785
785
}
786
786
}
787
787
State :: Draining => frame:: ConnectionClose {
788
788
error_code : TransportErrorCode :: NO_ERROR ,
789
789
frame_type : None ,
790
790
reason : Bytes :: new ( ) ,
791
791
}
792
- . encode ( & mut buf, max_frame_size) ,
792
+ . encode ( & mut buf. datagram_mut ( ) , max_frame_size) ,
793
793
_ => unreachable ! (
794
794
"tried to make a close packet when the connection wasn't closed"
795
795
) ,
@@ -817,8 +817,8 @@ impl Connection {
817
817
// above.
818
818
let mut builder = builder_storage. take ( ) . unwrap ( ) ;
819
819
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) ;
822
822
self . stats . frame_tx . path_response += 1 ;
823
823
builder. pad_to ( MIN_INITIAL_SIZE ) ;
824
824
builder. finish_and_track (
@@ -844,7 +844,7 @@ impl Connection {
844
844
let sent = self . populate_packet (
845
845
now,
846
846
space_id,
847
- & mut buf,
847
+ & mut buf. datagram_mut ( ) ,
848
848
builder. max_size ,
849
849
builder. exact_number ,
850
850
) ;
@@ -908,12 +908,12 @@ impl Connection {
908
908
PacketBuilder :: new ( now, space_id, self . rem_cids . active ( ) , & mut buf, true , self ) ?;
909
909
910
910
// 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 ) ;
912
912
self . stats . frame_tx . ping += 1 ;
913
913
914
914
// If supported by the peer, we want no delays to the probe's ACK
915
915
if self . peer_supports_ack_frequency ( ) {
916
- buf. write ( frame:: FrameType :: IMMEDIATE_ACK ) ;
916
+ buf. datagram_mut ( ) . write ( frame:: FrameType :: IMMEDIATE_ACK ) ;
917
917
self . stats . frame_tx . immediate_ack += 1 ;
918
918
}
919
919
@@ -986,8 +986,8 @@ impl Connection {
986
986
debug_assert_eq ! ( buf. datagram_start_offset( ) , 0 ) ;
987
987
let mut builder = PacketBuilder :: new ( now, SpaceId :: Data , * prev_cid, buf, false , self ) ?;
988
988
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) ;
991
991
self . stats . frame_tx . path_challenge += 1 ;
992
992
993
993
// An endpoint MUST expand datagrams that contain a PATH_CHALLENGE frame
@@ -3975,6 +3975,12 @@ impl BufLen for Vec<u8> {
3975
3975
}
3976
3976
}
3977
3977
3978
+ impl BufLen for bytes:: buf:: Limit < & mut Vec < u8 > > {
3979
+ fn len ( & self ) -> usize {
3980
+ self . get_ref ( ) . len ( )
3981
+ }
3982
+ }
3983
+
3978
3984
#[ cfg( test) ]
3979
3985
mod tests {
3980
3986
use super :: * ;
0 commit comments