Struct Request

Source
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

Source

pub fn new() -> Self

Creates a new Request instance with uninitialized members.

Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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 implement SetParameterValue.
§Returns:
  • Ok(StatusCode) - The status code after setting the parameter.
  • Err(String) - An error message if the update fails.
Source

pub fn set_parameters<T>( &self, paths: Vec<&str>, values: T, ) -> Result<StatusCode, String>
where T: SetParameterTuple,

Source

pub fn get_parameter<V>(&self, path: &str) -> Result<V, String>

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 the GetParameterValue trait to properly decode the parameter’s value from the server response.
§Returns:
  • Ok(V) - The parameter value successfully retrieved and decoded into the type V.
  • 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.
Source

pub fn get_parameters<T>(&self, paths: Vec<&str>) -> Result<T, String>
where T: GetParameterTuple,

Source

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 retrieved ParameterTree.
  • Err(String) - An error message if retrieving or decoding the parameter tree fails.
Source

pub fn create_group<I>( &self, parameters: I, group_name: &str, frequency_divider: u32, ) -> Result<GroupStatusMsg, String>
where I: Parameters,

Source

pub fn remove_group(&self, group_name: &str) -> Result<StatusCode, String>

Source

pub fn decode_message<T: Message + Default + Hash>( reply_slice: &[u8], ) -> Result<T, DecodeError>

Decodes a byte slice into a specific Protobuf message type.

§Arguments:
  • reply_slice - The received byte slice containing the message data.
§Returns:
  • Ok(T) - The decoded message of type T.
  • Err(DecodeError) - An error if decoding fails.

Trait Implementations§

Source§

impl Connection for Request

Implement the common trait for Request

Source§

fn connect( &mut self, url: &str, options: ConnectionOptions, ) -> Result<(), String>

Connect to a server
Source§

fn disconnect(&mut self) -> Result<(), String>

Disconnect from the server

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.