@@ -321,105 +321,6 @@ impl Context {
321321 !self . get_closed ( ) && keep_alive
322322 }
323323
324- /// Retrieves the remote socket address of the connection.
325- ///
326- /// # Returns
327- ///
328- /// - `Option<SocketAddr>` - The socket address of the remote peer if available.
329- pub async fn try_get_socket_addr ( & self ) -> Option < SocketAddr > {
330- self . try_get_stream ( )
331- . as_ref ( ) ?
332- . read ( )
333- . await
334- . peer_addr ( )
335- . ok ( )
336- }
337-
338- /// Retrieves the remote socket address.
339- ///
340- /// # Returns
341- ///
342- /// - `SocketAddr` - The socket address of the remote peer.
343- ///
344- /// # Panics
345- ///
346- /// - If the socket address is not found.
347- pub async fn get_socket_addr ( & self ) -> SocketAddr {
348- self . try_get_socket_addr ( ) . await . unwrap ( )
349- }
350-
351- /// Retrieves the remote socket address as a string.
352- ///
353- /// # Returns
354- ///
355- /// - `Option<String>` - The string representation of the socket address if available.
356- pub async fn try_get_socket_addr_string ( & self ) -> Option < String > {
357- self . try_get_socket_addr ( )
358- . await
359- . map ( |data| data. to_string ( ) )
360- }
361-
362- /// Retrieves the remote socket address as a string.
363- ///
364- /// # Returns
365- ///
366- /// - `String` - The string representation of the socket address.
367- ///
368- /// # Panics
369- ///
370- /// - If the socket address is not found.
371- pub async fn get_socket_addr_string ( & self ) -> String {
372- self . get_socket_addr ( ) . await . to_string ( )
373- }
374-
375- /// Retrieves the IP address part of the remote socket address.
376- ///
377- /// # Returns
378- ///
379- /// - `Option<SocketHost>` - The IP address of the remote peer.
380- pub async fn try_get_socket_host ( & self ) -> Option < SocketHost > {
381- self . try_get_socket_addr ( )
382- . await
383- . map ( |socket_addr : SocketAddr | socket_addr. ip ( ) )
384- }
385-
386- /// Retrieves the IP address part of the remote socket address.
387- ///
388- /// # Returns
389- ///
390- /// - `SocketHost` - The IP address of the remote peer.
391- ///
392- /// # Panics
393- ///
394- /// - If the socket address is not found.
395- pub async fn get_socket_host ( & self ) -> SocketHost {
396- self . try_get_socket_host ( ) . await . unwrap ( )
397- }
398-
399- /// Retrieves the port number part of the remote socket address.
400- ///
401- /// # Returns
402- ///
403- /// - `Option<SocketPort>` - The port number of the remote peer if available.
404- pub async fn try_get_socket_port ( & self ) -> Option < SocketPort > {
405- self . try_get_socket_addr ( )
406- . await
407- . map ( |socket_addr : SocketAddr | socket_addr. port ( ) )
408- }
409-
410- /// Retrieves the port number part of the remote socket address.
411- ///
412- /// # Returns
413- ///
414- /// - `SocketPort` - The port number of the remote peer.
415- ///
416- /// # Panics
417- ///
418- /// - If the socket address is not found.
419- pub async fn get_socket_port ( & self ) -> SocketPort {
420- self . try_get_socket_port ( ) . await . unwrap ( )
421- }
422-
423324 /// Attempts to retrieve a specific route parameter by its name.
424325 ///
425326 /// # Arguments
0 commit comments