Function run_server

Source
pub fn run_server<Req, Resp, S>(serve: S) -> Result<(), IpcError>
where Req: Serialize + for<'de> Deserialize<'de>, Resp: Serialize + for<'de> Deserialize<'de>, S: Serve<Req = Req, Resp = Resp>,
Expand description

Runs the server with the provided service implementation. This function listens for incoming requests, processes them using the provided service, and sends back the responses. It uses the inherited file descriptors for communication.

§Arguments

  • serve - A mutable reference to the service implementation that handles the requests and generates the responses. The service must implement the Serve trait with the appropriate request and response types.

§Type Parameters

  • Req - The type of the request messages. It must implement Serialize and Deserialize.
  • Resp - The type of the response messages. It must implement Serialize and Deserialize.
  • S - The type of the service implementation. It must implement the Serve trait with Req as the request type and Resp as the response type.

§Returns

A Result indicating the success or failure of the server execution. If the server runs successfully, it never returns. If an error occurs, it returns an IpcError.

§Errors

This function returns an IpcError if any of the following conditions occur:

  • The inherited file descriptors are not exactly two.
  • An error occurs during the execution of the channel.