Skip to content

Commit 6c7fb65

Browse files
committed
Merge branch 'main' into ps/state-traits
2 parents 0d26728 + ad572b2 commit 6c7fb65

27 files changed

+707
-66
lines changed

Cargo.lock

Lines changed: 1 addition & 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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ wasm = [
2121
bitwarden-error = { workspace = true }
2222
js-sys = { workspace = true, optional = true }
2323
serde = { workspace = true }
24+
serde_json = { workspace = true }
2425
thiserror = { workspace = true }
25-
tokio = { features = ["sync"], workspace = true }
26+
tokio = { features = ["sync", "time"], workspace = true }
2627
tsify-next = { workspace = true, optional = true }
2728
wasm-bindgen = { workspace = true, optional = true }
2829
wasm-bindgen-futures = { workspace = true, optional = true }
2930

31+
[dev-dependencies]
32+
tokio = { workspace = true, features = ["rt"] }
33+
3034
[lints]
3135
workspace = true

crates/bitwarden-ipc/src/endpoint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
22
#[cfg(feature = "wasm")]
33
use {tsify_next::Tsify, wasm_bindgen::prelude::*};
44

5-
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)]
5+
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
66
#[cfg_attr(feature = "wasm", derive(Tsify), tsify(into_wasm_abi, from_wasm_abi))]
77
pub enum Endpoint {
88
Web { id: i32 },

crates/bitwarden-ipc/src/error.rs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,47 @@ use thiserror::Error;
33
#[derive(Clone, Debug, Error, PartialEq, Eq)]
44
pub enum SendError<Crypto, Com> {
55
#[error("Crypto error: {0}")]
6-
CryptoError(Crypto),
6+
Crypto(Crypto),
77

88
#[error("Communication error: {0}")]
9-
CommunicationError(Com),
9+
Communication(Com),
1010
}
1111

1212
#[derive(Clone, Debug, Error, PartialEq, Eq)]
1313
pub enum ReceiveError<Crypto, Com> {
14+
#[error("The receive operation timed out")]
15+
Timeout,
16+
1417
#[error("Crypto error: {0}")]
15-
CryptoError(Crypto),
18+
Crypto(Crypto),
1619

1720
#[error("Communication error: {0}")]
18-
CommunicationError(Com),
21+
Communication(Com),
22+
}
23+
24+
#[derive(Clone, Debug, Error, PartialEq, Eq)]
25+
pub enum TypedReceiveError<Typing, Crypto, Com> {
26+
#[error("Typing error: {0}")]
27+
Typing(Typing),
28+
29+
#[error("The receive operation timed out")]
30+
Timeout,
31+
32+
#[error("Crypto error: {0}")]
33+
Crypto(Crypto),
34+
35+
#[error("Communication error: {0}")]
36+
Communication(Com),
37+
}
38+
39+
impl<Typing, Crypto, Com> From<ReceiveError<Crypto, Com>>
40+
for TypedReceiveError<Typing, Crypto, Com>
41+
{
42+
fn from(value: ReceiveError<Crypto, Com>) -> Self {
43+
match value {
44+
ReceiveError::Timeout => TypedReceiveError::Timeout,
45+
ReceiveError::Crypto(crypto) => TypedReceiveError::Crypto(crypto),
46+
ReceiveError::Communication(com) => TypedReceiveError::Communication(com),
47+
}
48+
}
1949
}

0 commit comments

Comments
 (0)