11use crate :: * ;
22
3- /// Default implementation for UdpRequest.
3+ /// Implements the ` Default` trait for ` UdpRequest` .
44impl Default for UdpRequest {
5- /// Creates a default UdpRequest instance.
5+ /// Creates a default ` UdpRequest` instance.
66 ///
77 /// # Returns
88 ///
9- /// - `UdpRequest ` - Default request with default config and empty response.
9+ /// - `Self ` - A new `UdpRequest` with default configuration and an empty response.
1010 fn default ( ) -> Self {
1111 Self {
1212 config : Arc :: new ( RwLock :: new ( Config :: default ( ) ) ) ,
@@ -15,17 +15,18 @@ impl Default for UdpRequest {
1515 }
1616}
1717
18+ /// Implementation of `UdpRequest`.
1819impl UdpRequest {
19- /// Sends UDP request data through socket .
20+ /// Sends a UDP request and reads the response .
2021 ///
2122 /// # Arguments
2223 ///
23- /// - `&mut UdpSocket` - UDP socket for communication .
24- /// - `&[u8]` - Data to send.
24+ /// - `&mut UdpSocket` - The UDP socket to use for sending and receiving data .
25+ /// - `&[u8]` - The data to send in the request .
2526 ///
2627 /// # Returns
2728 ///
28- /// - `Result<BoxResponseTrait, RequestError>` - Response or error .
29+ /// - `Result<BoxResponseTrait, RequestError>` - A `Result` containing the response as a boxed trait object or a `RequestError` .
2930 fn send_request (
3031 & mut self ,
3132 socket : & mut UdpSocket ,
@@ -37,15 +38,15 @@ impl UdpRequest {
3738 self . read_response ( socket)
3839 }
3940
40- /// Reads response from UDP socket.
41+ /// Reads the response from the UDP socket.
4142 ///
4243 /// # Arguments
4344 ///
44- /// - `&mut UdpSocket` - UDP socket for communication .
45+ /// - `&mut UdpSocket` - The UDP socket to read the response from .
4546 ///
4647 /// # Returns
4748 ///
48- /// - `Result<BoxResponseTrait, RequestError>` - Response or error .
49+ /// - `Result<BoxResponseTrait, RequestError>` - A `Result` containing the response as a boxed trait object or a `RequestError` .
4950 fn read_response ( & mut self , socket : & mut UdpSocket ) -> Result < BoxResponseTrait , RequestError > {
5051 let cfg_buffer_size: usize = self
5152 . config
@@ -64,16 +65,16 @@ impl UdpRequest {
6465 ) ) ;
6566 }
6667
67- /// Creates and configures UDP socket for connection.
68+ /// Creates and configures a UDP socket for the connection.
6869 ///
6970 /// # Arguments
7071 ///
71- /// - `String` - Host address.
72- /// - `usize` - Port number.
72+ /// - `String` - The host address to connect to .
73+ /// - `usize` - The port number to connect to .
7374 ///
7475 /// # Returns
7576 ///
76- /// - `Result<UdpSocket, RequestError>` - Configured socket or error .
77+ /// - `Result<UdpSocket, RequestError>` - A `Result` containing the configured `UdpSocket` or a `RequestError` .
7778 fn get_connection_socket ( & self , host : String , port : usize ) -> Result < UdpSocket , RequestError > {
7879 let host_port: String = format ! ( "{}:{}" , host. clone( ) , port) ;
7980 let cfg_timeout: u64 = self
@@ -97,19 +98,19 @@ impl UdpRequest {
9798 }
9899}
99100
100- /// RequestTrait implementation for UdpRequest.
101+ /// Implements the `RequestTrait` for ` UdpRequest` .
101102impl RequestTrait for UdpRequest {
102103 type RequestResult = RequestResult ;
103104
104- /// Sends UDP request with given data.
105+ /// Sends a UDP request with the given data.
105106 ///
106107 /// # Arguments
107108 ///
108- /// - `&[u8]` - Data to send.
109+ /// - `&[u8]` - The data to send in the request .
109110 ///
110111 /// # Returns
111112 ///
112- /// - `RequestResult` - Response or error.
113+ /// - `Self:: RequestResult` - The result of the request, containing either the response or an error.
113114 fn send ( & mut self , data : & [ u8 ] ) -> Self :: RequestResult {
114115 let cfg_timeout: Config = self
115116 . config
0 commit comments