pub struct Request { /* private fields */ }
Expand description
Represents a request client that manages socket-based connections and interacts with the server.
Implementations§
Source§impl Request
impl Request
Sourcepub fn connect(
&mut self,
url: &str,
connection_options: ConnectionOptions,
) -> Result<(), String>
pub fn connect( &mut self, url: &str, connection_options: ConnectionOptions, ) -> Result<(), String>
Establishes a connection to a specified server URL using the given configuration options.
§Arguments:
url
- The server’s address (e.g., “tcp://127.0.0.1:5555”).connection_options
- The connection settings, including TLS certificate and timeouts.
§Returns:
Ok(())
if the connection is successful.Err(String)
with the error message if the operation fails.
Sourcepub fn disconnect(&mut self) -> Result<(), String>
pub fn disconnect(&mut self) -> Result<(), String>
Disconnects the current connection and frees the associated resources.
§Returns:
Ok(())
if the disconnection is successful.Err(String)
with the error message if the operation fails.
Sourcepub fn login(
&self,
username: String,
password: String,
) -> Result<StatusCode, String>
pub fn login( &self, username: String, password: String, ) -> Result<StatusCode, String>
Sends a login message to the server with the specified username and password.
§Arguments:
username
- The username to authenticate with.password
- The password for authentication.
§Returns:
Ok(StatusCode)
- The status code representing the login response.Err(String)
- An error message if the login fails.
Sourcepub fn logout(&self) -> Result<StatusCode, String>
pub fn logout(&self) -> Result<StatusCode, String>
Sends a logout message to the server.
§Returns:
Ok(StatusCode)
- The status code representing the logout response.Err(String)
- An error message if the logout fails.
Sourcepub fn request_parameter_tree(&mut self) -> Result<StatusCode, String>
pub fn request_parameter_tree(&mut self) -> Result<StatusCode, String>
Requests and updates the client’s parameter tree from the server.
§Returns:
Ok(StatusCode)
- The status code indicating the result of the request.Err(String)
- An error message if the request fails.
Sourcepub fn set_parameter<V>(
&self,
path: &str,
value: V,
) -> Result<StatusCode, String>
pub fn set_parameter<V>( &self, path: &str, value: V, ) -> Result<StatusCode, String>
Updates a specific parameter on the server with the provided value.
§Arguments:
path
- The hierarchical path to the parameter being updated.value
- The new value for the parameter. Must implementSetParameterValue
.
§Returns:
Ok(StatusCode)
- The status code after setting the parameter.Err(String)
- An error message if the update fails.
pub fn set_parameters<T>(
&self,
paths: Vec<&str>,
values: T,
) -> Result<StatusCode, String>where
T: SetParameterTuple,
Sourcepub fn get_parameter<V>(&self, path: &str) -> Result<V, String>where
V: GetParameterValue + Default,
pub fn get_parameter<V>(&self, path: &str) -> Result<V, String>where
V: GetParameterValue + Default,
Retrieves the value of a parameter from the server for the given path.
§Arguments:
path
- The hierarchical path of the parameter to retrieve.
§Type Parameters:
V
- The expected value type of the parameter. This type must implement theGetParameterValue
trait to properly decode the parameter’s value from the server response.
§Returns:
Ok(V)
- The parameter value successfully retrieved and decoded into the typeV
.Err(String)
- An error message if the retrieval or decoding fails.
§Errors:
This function will return an error if:
- The parameter’s data type cannot be identified.
- The path to the parameter is invalid or non-existent.
- There is an issue encoding the request or decoding the response from the server.
pub fn get_parameters<T>(&self, paths: Vec<&str>) -> Result<T, String>where
T: GetParameterTuple,
Sourcepub fn get_parameter_tree(&self) -> Result<(StatusCode, ParameterTree), String>
pub fn get_parameter_tree(&self) -> Result<(StatusCode, ParameterTree), String>
Retrieves the server’s parameter tree.
This function sends a GetParameterTreeMsg
request to the server and decodes the response
into a ParameterTree
object along with a status code indicating the result.
§Returns:
Ok((StatusCode, ParameterTree))
- A tuple containing the status code and the retrievedParameterTree
.Err(String)
- An error message if retrieving or decoding the parameter tree fails.