use crypto_proto::generated::proto::reallyme::crypto::v1::CryptoOperationResponse;
use crypto_proto::operation_request_wire::{
decode_operation_request, decode_operation_request_json,
};
use crypto_proto::operation_response_wire::encode_operation_response_or_error;
use zeroize::Zeroizing;
use super::error::error_response;
use super::request::process_operation_request;
#[must_use]
pub fn process_operation_response(request_bytes: &[u8]) -> Zeroizing<Vec<u8>> {
encode_operation_response_or_error(&process_operation_response_output(request_bytes))
}
#[must_use]
pub fn process_operation_response_output(request_bytes: &[u8]) -> CryptoOperationResponse {
match decode_operation_request(request_bytes) {
Ok(request) => process_operation_request(request),
Err(error) => error_response(error),
}
}
#[must_use]
pub fn process_operation_response_json(request_json: &[u8]) -> Zeroizing<Vec<u8>> {
encode_operation_response_or_error(&process_operation_response_json_output(request_json))
}
#[must_use]
pub fn process_operation_response_json_output(request_json: &[u8]) -> CryptoOperationResponse {
match decode_operation_request_json(request_json) {
Ok(request) => process_operation_request(request),
Err(error) => error_response(error),
}
}