@@ -245,7 +245,7 @@ pub struct NewConnection {
245245impl NewConnection {
246246 fn new ( conn : ConnectionRef ) -> Self {
247247 Self {
248- connection : Connection ( conn. clone ( ) ) ,
248+ connection : Connection { conn : conn . clone ( ) } ,
249249 uni_streams : IncomingUniStreams ( conn. clone ( ) ) ,
250250 bi_streams : IncomingBiStreams ( conn. clone ( ) ) ,
251251 datagrams : Datagrams ( conn) ,
@@ -311,7 +311,9 @@ impl Future for ConnectionDriver {
311311///
312312/// [`Connection::close()`]: Connection::close
313313#[ derive( Debug , Clone ) ]
314- pub struct Connection ( ConnectionRef ) ;
314+ pub struct Connection {
315+ conn : ConnectionRef ,
316+ }
315317
316318impl Connection {
317319 /// Initiate a new outgoing unidirectional stream.
@@ -321,7 +323,7 @@ impl Connection {
321323 /// actually used.
322324 pub fn open_uni ( & self ) -> OpenUni {
323325 OpenUni {
324- conn : self . 0 . clone ( ) ,
326+ conn : self . conn . clone ( ) ,
325327 state : broadcast:: State :: default ( ) ,
326328 }
327329 }
@@ -333,7 +335,7 @@ impl Connection {
333335 /// actually used.
334336 pub fn open_bi ( & self ) -> OpenBi {
335337 OpenBi {
336- conn : self . 0 . clone ( ) ,
338+ conn : self . conn . clone ( ) ,
337339 state : broadcast:: State :: default ( ) ,
338340 }
339341 }
@@ -354,7 +356,7 @@ impl Connection {
354356 /// [`finish`]: crate::SendStream::finish
355357 /// [`SendStream`]: crate::SendStream
356358 pub fn close ( & self , error_code : VarInt , reason : & [ u8 ] ) {
357- let conn = & mut * self . 0 . lock ( "close" ) ;
359+ let conn = & mut * self . conn . lock ( "close" ) ;
358360 conn. close ( error_code, Bytes :: copy_from_slice ( reason) ) ;
359361 }
360362
@@ -364,7 +366,7 @@ impl Connection {
364366 /// and `data` must both fit inside a single QUIC packet and be smaller than the maximum
365367 /// dictated by the peer.
366368 pub fn send_datagram ( & self , data : Bytes ) -> Result < ( ) , SendDatagramError > {
367- let conn = & mut * self . 0 . lock ( "send_datagram" ) ;
369+ let conn = & mut * self . conn . lock ( "send_datagram" ) ;
368370 if let Some ( ref x) = conn. error {
369371 return Err ( SendDatagramError :: ConnectionLost ( x. clone ( ) ) ) ;
370372 }
@@ -394,7 +396,7 @@ impl Connection {
394396 ///
395397 /// [`send_datagram()`]: Connection::send_datagram
396398 pub fn max_datagram_size ( & self ) -> Option < usize > {
397- self . 0
399+ self . conn
398400 . lock ( "max_datagram_size" )
399401 . inner
400402 . datagrams ( )
@@ -406,7 +408,7 @@ impl Connection {
406408 /// If `ServerConfig::migration` is `true`, clients may change addresses at will, e.g. when
407409 /// switching to a cellular internet connection.
408410 pub fn remote_address ( & self ) -> SocketAddr {
409- self . 0 . lock ( "remote_address" ) . inner . remote_address ( )
411+ self . conn . lock ( "remote_address" ) . inner . remote_address ( )
410412 }
411413
412414 /// The local IP address which was used when the peer established
@@ -424,22 +426,22 @@ impl Connection {
424426 /// On all non-supported platforms the local IP address will not be available,
425427 /// and the method will return `None`.
426428 pub fn local_ip ( & self ) -> Option < IpAddr > {
427- self . 0 . lock ( "local_ip" ) . inner . local_ip ( )
429+ self . conn . lock ( "local_ip" ) . inner . local_ip ( )
428430 }
429431
430432 /// Current best estimate of this connection's latency (round-trip-time)
431433 pub fn rtt ( & self ) -> Duration {
432- self . 0 . lock ( "rtt" ) . inner . rtt ( )
434+ self . conn . lock ( "rtt" ) . inner . rtt ( )
433435 }
434436
435437 /// Returns connection statistics
436438 pub fn stats ( & self ) -> ConnectionStats {
437- self . 0 . lock ( "stats" ) . inner . stats ( )
439+ self . conn . lock ( "stats" ) . inner . stats ( )
438440 }
439441
440442 /// Current state of the congestion control algorithm, for debugging purposes
441443 pub fn congestion_state ( & self ) -> Box < dyn Controller > {
442- self . 0
444+ self . conn
443445 . lock ( "congestion_state" )
444446 . inner
445447 . congestion_state ( )
@@ -454,7 +456,7 @@ impl Connection {
454456 ///
455457 /// [`Connection::handshake_data()`]: crate::Connecting::handshake_data
456458 pub fn handshake_data ( & self ) -> Option < Box < dyn Any > > {
457- self . 0
459+ self . conn
458460 . lock ( "handshake_data" )
459461 . inner
460462 . crypto_session ( )
@@ -467,7 +469,7 @@ impl Connection {
467469 /// [`Session`](proto::crypto::Session). For the default `rustls` session, the return value can
468470 /// be [`downcast`](Box::downcast) to a <code>Vec<[rustls::Certificate](rustls::Certificate)></code>
469471 pub fn peer_identity ( & self ) -> Option < Box < dyn Any > > {
470- self . 0
472+ self . conn
471473 . lock ( "peer_identity" )
472474 . inner
473475 . crypto_session ( )
@@ -479,13 +481,16 @@ impl Connection {
479481 /// Peer addresses and connection IDs can change, but this value will remain
480482 /// fixed for the lifetime of the connection.
481483 pub fn stable_id ( & self ) -> usize {
482- self . 0 . stable_id ( )
484+ self . conn . stable_id ( )
483485 }
484486
485487 // Update traffic keys spontaneously for testing purposes.
486488 #[ doc( hidden) ]
487489 pub fn force_key_update ( & self ) {
488- self . 0 . lock ( "force_key_update" ) . inner . initiate_key_update ( )
490+ self . conn
491+ . lock ( "force_key_update" )
492+ . inner
493+ . initiate_key_update ( )
489494 }
490495
491496 /// Derive keying material from this connection's TLS session secrets.
@@ -502,7 +507,7 @@ impl Connection {
502507 label : & [ u8 ] ,
503508 context : & [ u8 ] ,
504509 ) -> Result < ( ) , proto:: crypto:: ExportKeyingMaterialError > {
505- self . 0
510+ self . conn
506511 . lock ( "export_keying_material" )
507512 . inner
508513 . crypto_session ( )
0 commit comments