Skip to content

Commit b382bf3

Browse files
committed
Upgrade discro to v0.32.0
1 parent 1cbc535 commit b382bf3

File tree

5 files changed

+45
-49
lines changed

5 files changed

+45
-49
lines changed

Cargo.lock

+15-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/desktop-app/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ workspace = true
1818

1919
[dependencies]
2020
anyhow.workspace = true
21-
discro = { version = "0.29.4", features = ["tokio"] }
21+
discro = { version = "0.32.0", features = ["tokio"] }
2222
highway = { version = "1.3.0" }
2323
log.workspace = true
2424
ron = "0.8.1"

crates/desktop-app/src/lib.rs

+27-31
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use std::ops::{Add, AddAssign};
55

6-
use discro::Publisher;
6+
use discro::{ModifyStatus, Publisher};
77
use tokio::task::JoinHandle;
88

99
pub use aoide_backend_embedded::Environment;
@@ -87,37 +87,38 @@ impl AddAssign for ActionEffect {
8787
}
8888
}
8989

90+
impl ModifyStatus for ActionEffect {
91+
fn is_modified(&self) -> bool {
92+
match self {
93+
Self::Unchanged => false,
94+
Self::MaybeChanged | Self::Changed => true,
95+
}
96+
}
97+
}
98+
9099
pub(crate) fn modify_shared_state_action_effect<State>(
91100
shared_state: &Publisher<State>,
92101
modify_state: impl FnOnce(&mut State) -> ActionEffect,
93102
) -> ActionEffect {
94-
let mut effect = ActionEffect::MaybeChanged;
95-
shared_state.modify(|state| {
96-
effect = modify_state(state);
97-
match effect {
98-
ActionEffect::Unchanged => false,
99-
ActionEffect::MaybeChanged | ActionEffect::Changed => true,
100-
}
101-
});
102-
effect
103+
shared_state.modify(modify_state)
104+
}
105+
106+
struct ActionEffectResult<Result>(ActionEffect, Result);
107+
108+
impl<Result> ModifyStatus for ActionEffectResult<Result> {
109+
fn is_modified(&self) -> bool {
110+
self.0.is_modified()
111+
}
103112
}
104113

105114
pub(crate) fn modify_shared_state_action_effect_result<State, Result>(
106115
shared_state: &Publisher<State>,
107116
modify_state: impl FnOnce(&mut State) -> (ActionEffect, Result),
108117
) -> (ActionEffect, Result) {
109-
let mut effect = ActionEffect::MaybeChanged;
110-
let mut result = None;
111-
shared_state.modify(|state| {
112-
let (modify_effect, modify_result) = modify_state(state);
113-
effect = modify_effect;
114-
result = Some(modify_result);
115-
match modify_effect {
116-
ActionEffect::Unchanged => false,
117-
ActionEffect::MaybeChanged | ActionEffect::Changed => true,
118-
}
118+
let ActionEffectResult(effect, result) = shared_state.modify(|state| {
119+
let (effect, result) = modify_state(state);
120+
ActionEffectResult(effect, result)
119121
});
120-
let result = result.expect("has been set");
121122
(effect, result)
122123
}
123124

@@ -126,15 +127,10 @@ pub(crate) fn modify_shared_state_result<State, Result>(
126127
modify_state: impl FnOnce(&mut State) -> Result,
127128
action_effect: impl FnOnce(&Result) -> ActionEffect,
128129
) -> Result {
129-
let mut result = None;
130-
shared_state.modify(|state| {
131-
let modify_result = modify_state(state);
132-
let modified = match action_effect(&modify_result) {
133-
ActionEffect::Unchanged => false,
134-
ActionEffect::MaybeChanged | ActionEffect::Changed => true,
135-
};
136-
result = Some(modify_result);
137-
modified
130+
let ActionEffectResult(_effect, result) = shared_state.modify(|state| {
131+
let result = modify_state(state);
132+
let effect = action_effect(&result);
133+
ActionEffectResult(effect, result)
138134
});
139-
result.expect("has been set")
135+
result
140136
}

file-collection-app/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ workspace = true
1717
[dependencies]
1818
anyhow.workspace = true
1919
directories = "6.0.0"
20-
discro = "0.29.4"
20+
discro = "0.32.0"
2121
itertools = "0.14.0"
2222
env_logger = "0.11.6"
2323
url.workspace = true

websrv/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ workspace = true
1717
[dependencies]
1818
anyhow.workspace = true
1919
directories = "6.0.0"
20-
discro = { version = "0.29.4", features = ["tokio"] }
20+
discro = { version = "0.32.0", features = ["tokio"] }
2121
dotenvy = "0.15.7"
2222
log = { version = "0.4.25", features = ["release_max_level_debug"] }
2323
parking_lot = "0.12.3"

0 commit comments

Comments
 (0)