Skip to main content

bitwarden_ipc/rpc/
response_message.rs

1use erased_serde::Serialize as ErasedSerialize;
2use serde::{Deserialize, Serialize};
3
4use super::error::RpcError;
5
6/// Prefix for the per-request dedicated response topic, formatted as
7/// `"{RPC_RESPONSE_PAYLOAD_TYPE_NAME}:{request_id}"`. Each response is published on the dedicated
8/// topic carried by its request, so response types do not implement
9/// [`PayloadTypeName`](crate::message::PayloadTypeName).
10pub const RPC_RESPONSE_PAYLOAD_TYPE_NAME: &str = "RpcResponseMessage";
11
12#[derive(Debug, Clone, Serialize, Deserialize)]
13pub struct IncomingRpcResponseMessage<T> {
14    pub result: Result<T, RpcError>,
15    pub request_id: String,
16    pub request_type: String,
17}
18
19#[derive(Serialize)]
20pub struct OutgoingRpcResponseMessage<'a> {
21    pub result: Result<Box<dyn ErasedSerialize>, RpcError>,
22    pub request_id: &'a str,
23    pub request_type: &'a str,
24}