Skip to content

Commit b8a2eca

Browse files
cratelynconorsch
authored andcommitted
responder: šŸ£ add a new(Address) constructor
1 parent 14d3df7 commit b8a2eca

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ā€Žsrc/responder/request.rs

+14
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ impl Request {
2727
&self.addresses
2828
}
2929

30+
/// Create a new request for this address.
31+
///
32+
/// Returns a receiver for the response to this request, as well as the request itself.
33+
pub fn new(address: Address) -> (oneshot::Receiver<Response>, Self) {
34+
let (tx, rx) = oneshot::channel();
35+
let addresses = vec![AddressOrAlmost::Address(Box::new(address))];
36+
let req = Self {
37+
addresses,
38+
response: tx,
39+
};
40+
41+
(rx, req)
42+
}
43+
3044
/// Create a new request by scanning the contents of a [`Message`].
3145
///
3246
/// Returns a receiver for the response to this request, as well as the request itself.

0 commit comments

Comments
Ā (0)