pub struct Mr<M: Message>(pub M::Response);
Expand description
§Message Response
Response type from a handler which directly sends a response for a specific message
use interlink::prelude::*;
#[derive(Service)]
struct Test { value: String };
#[derive(Message)]
#[msg(rtype="String")]
struct TestMessage {
value: String,
}
impl Handler<TestMessage> for Test {
type Response = Mr<TestMessage>;
fn handle(&mut self, msg: TestMessage, ctx: &mut ServiceContext<Self>) -> Self::Response {
self.value = msg.value;
Mr("Response".to_string())
}
}
#[tokio::test]
async fn test() {
let service = Test { value: "Default".to_string() };
let link = service.start();
let res: String = link
.send(TestMessage {
value: "Example".to_string()
})
.await
.unwrap();
assert_eq!(&res, "Response")
}
Tuple Fields§
§0: M::Response
Trait Implementations§
Auto Trait Implementations§
impl<M> Freeze for Mr<M>
impl<M> RefUnwindSafe for Mr<M>
impl<M> Send for Mr<M>
impl<M> Sync for Mr<M>
impl<M> Unpin for Mr<M>
impl<M> UnwindSafe for Mr<M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more