Skip to content

Commit dd409b8

Browse files
committed
Add methods to party to change its components
Signed-off-by: maurges <nikita@dfns.co>
1 parent 100b267 commit dd409b8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

round-based/src/party.rs

+20
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,26 @@ impl<M, D, X> MpcParty<M, D, X>
123123
where
124124
D: Delivery<M>,
125125
{
126+
/// Modify the delivery of this party while keeping everything else the same
127+
pub fn map_delivery<D2>(self, f: impl FnOnce(D) -> D2) -> MpcParty<M, D2, X> {
128+
let delivery = f(self.delivery);
129+
MpcParty {
130+
delivery,
131+
runtime: self.runtime,
132+
_msg: self._msg,
133+
}
134+
}
135+
136+
/// Modify the runtime of this party while keeping everything else the same
137+
pub fn map_runtime<R>(self, f: impl FnOnce(X) -> R) -> MpcParty<M, D, R> {
138+
let runtime = f(self.runtime);
139+
MpcParty {
140+
delivery: self.delivery,
141+
runtime,
142+
_msg: self._msg,
143+
}
144+
}
145+
126146
/// Specifies a [async runtime](runtime)
127147
pub fn set_runtime<R>(self, runtime: R) -> MpcParty<M, D, R>
128148
where

0 commit comments

Comments
 (0)