Skip to content

Commit 025f818

Browse files
authored
[PM-18042] Build request response structure (#275)
## 🎟️ Tracking <!-- Paste the link to the Jira or GitHub issue or otherwise describe / point to where this change is coming from. --> ## 📔 Objective <!-- Describe what the purpose of this PR is, for example what bug you're fixing or new feature you're adding. --> ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## 🦮 Reviewer guidelines <!-- Suggested interactions but feel free to use (or not) as you desire! --> - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes
1 parent a3d748a commit 025f818

File tree

23 files changed

+818
-73
lines changed

23 files changed

+818
-73
lines changed

Cargo.lock

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bitwarden-ipc/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ wasm = [
2020
] # WASM support
2121

2222
[dependencies]
23+
async-trait = { workspace = true }
2324
bitwarden-error = { workspace = true }
2425
bitwarden-threading = { workspace = true }
26+
erased-serde = ">=0.4.6, <0.5"
2527
js-sys = { workspace = true, optional = true }
2628
log = { workspace = true }
2729
serde = { workspace = true }
2830
serde_json = { workspace = true }
2931
thiserror = { workspace = true }
3032
tokio = { features = ["sync", "time", "rt"], workspace = true }
3133
tsify-next = { workspace = true, optional = true }
34+
uuid = { workspace = true }
3235
wasm-bindgen = { workspace = true, optional = true }
3336
wasm-bindgen-futures = { workspace = true, optional = true }
3437

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
use serde::{Deserialize, Serialize};
2+
#[cfg(feature = "wasm")]
3+
use {tsify_next::Tsify, wasm_bindgen::prelude::*};
4+
5+
use crate::{rpc::request::RpcRequest, RpcHandler};
6+
7+
#[derive(Debug, Clone, Serialize, Deserialize)]
8+
pub struct DiscoverRequest;
9+
10+
#[derive(Debug, Clone, Serialize, Deserialize)]
11+
#[cfg_attr(feature = "wasm", derive(Tsify), tsify(into_wasm_abi, from_wasm_abi))]
12+
pub struct DiscoverResponse {
13+
pub version: String,
14+
}
15+
16+
impl RpcRequest for DiscoverRequest {
17+
type Response = DiscoverResponse;
18+
19+
const NAME: &str = "DiscoverRequest";
20+
}
21+
22+
pub struct DiscoverHandler {
23+
response: DiscoverResponse,
24+
}
25+
26+
impl DiscoverHandler {
27+
pub fn new(response: DiscoverResponse) -> Self {
28+
Self { response }
29+
}
30+
}
31+
32+
impl RpcHandler for DiscoverHandler {
33+
type Request = DiscoverRequest;
34+
35+
async fn handle(&self, _request: Self::Request) -> DiscoverResponse {
36+
self.response.clone()
37+
}
38+
}

0 commit comments

Comments
 (0)