Skip to content

Commit 64a8bd2

Browse files
authored
Refactor: Use serde instead of TryFrom<Vec<u8>> traits in IPC (#316)
## 🎟️ Tracking <!-- Paste the link to the Jira or GitHub issue or otherwise describe / point to where this change is coming from. --> ## 📔 Objective Refactoring the IPC to use serde instead. Putting this in a separate PR to make reviewing easier ## ⏰ 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 4de8897 commit 64a8bd2

File tree

16 files changed

+253
-329
lines changed

16 files changed

+253
-329
lines changed

Cargo.lock

Lines changed: 17 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ wasm = [
2323
async-trait = { workspace = true }
2424
bitwarden-error = { workspace = true }
2525
bitwarden-threading = { workspace = true }
26+
erased-serde = "0.4.6"
2627
js-sys = { workspace = true, optional = true }
2728
log = { workspace = true }
2829
serde = { workspace = true }

crates/bitwarden-ipc/src/discover/mod.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::convert::Infallible;
2-
31
use serde::{Deserialize, Serialize};
42
#[cfg(feature = "wasm")]
53
use {tsify_next::Tsify, wasm_bindgen::prelude::*};
@@ -23,38 +21,6 @@ impl RpcRequest for DiscoverRequest {
2321
}
2422
}
2523

26-
impl TryFrom<DiscoverRequest> for Vec<u8> {
27-
type Error = Infallible;
28-
29-
fn try_from(_value: DiscoverRequest) -> Result<Self, Self::Error> {
30-
Ok(vec![])
31-
}
32-
}
33-
34-
impl TryFrom<Vec<u8>> for DiscoverRequest {
35-
type Error = Infallible;
36-
37-
fn try_from(_value: Vec<u8>) -> Result<Self, Self::Error> {
38-
Ok(DiscoverRequest)
39-
}
40-
}
41-
42-
impl TryFrom<DiscoverResponse> for Vec<u8> {
43-
type Error = serde_json::Error;
44-
45-
fn try_from(value: DiscoverResponse) -> Result<Self, Self::Error> {
46-
serde_json::to_vec(&value)
47-
}
48-
}
49-
50-
impl TryFrom<Vec<u8>> for DiscoverResponse {
51-
type Error = serde_json::Error;
52-
53-
fn try_from(value: Vec<u8>) -> Result<Self, Self::Error> {
54-
serde_json::from_slice(&value)
55-
}
56-
}
57-
5824
pub struct DiscoverHandler {
5925
response: DiscoverResponse,
6026
}

0 commit comments

Comments
 (0)