# ComputeResponse Class

The `ComputeResponse` class represents the response received from the OpenVector network after a computation has been performed. It contains the status of the computation and any resulting data.

### Public Enums

#### `enum class Status`

Indicates the status of the computation.

* **Values:**
  * `OK`: The computation was successful.
  * `ERROR`: An error occurred during the computation.

### Constructors

#### `ComputeResponse(Status status, std::string data);`

Creates a compute response with the specified status and data.

```cpp
ComputeResponse response(ComputeResponse::Status::OK, resultData);
```

* **Parameters:**
  * `status`: The status of the computation (`OK` or `ERROR`).
  * `data`: The result data as a string. The format and content depend on the computation performed.

### Member Functions

* **`Status& status();`**

  Returns a reference to the status of the computation.
* **`const Status& status() const;`**

  Returns a constant reference to the status of the computation.
* **`std::string& data();`**

  Returns a reference to the result data string.
* **`const std::string& data() const;`**

  Returns a constant reference to the result data string.
* **`std::string to_string() const;`**

  Serializes the compute response to a string.
* **`static ComputeResponse from_string(const std::string& str);`**

  Deserializes a compute response from a string.

### Usage Example

```cpp
// After performing a compute operation using ClientNode
ComputeResponse* response = nullptr;
clientNode.compute(request, &response);

if (response) {
    if (response->status() == ComputeResponse::Status::OK) {
        // Deserialize the result
        PlainTextImpl resultPt = cs.deserialize_plaintext(response->data());
        float resultValue = cs.get_float_from_plaintext(resultPt);
        // Use the resultValue
    } else {
        // Handle error
        std::cerr << "Computation failed." << std::endl;
    }
} else {
    // Handle null response
    std::cerr << "No response received from the server." << std::endl;
}
```

### Notes

* The `data` field contains the serialized result of the computation. You need to deserialize it using the appropriate method from the `CryptoSystem`.
* Always check the `status` before attempting to use the `data`.
* In case of an error, the `data` field may contain an error message or be empty.

### See Also

* [ClientNode Class](/docs/api-references/markdown.md)
* [ComputeRequest Class](/docs/api-references/openapi.md)
* [CryptoSystem Interface](/docs/api-references/editor.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://openvector.gitbook.io/docs/api-references/computeresponse-class.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
