pub struct RFn<A, R, Codec = Default> { /* private fields */ }
rfn
only.Expand description
Calls an async Fn function possibly located on a remote endpoint.
The remote function can be cloned and executed simultaneously from multiple callers. For each invocation a new async task is spawned.
The function can take between zero and ten arguments.
§Example
In the following example the server sends a remote function that adds two numbers to the client. The client receives the remote function and calls it two times.
use remoc::prelude::*;
type AddRFn = rfn::RFn<(u32, u32), Result<u32, rfn::CallError>>;
// This would be run on the client.
async fn client(mut rx: rch::base::Receiver<AddRFn>) {
let rfn = rx.recv().await.unwrap().unwrap();
assert_eq!(rfn.call(3, 5).await.unwrap(), 8);
assert_eq!(rfn.call(2, 10).await.unwrap(), 12);
}
// This would be run on the server.
async fn server(mut tx: rch::base::Sender<AddRFn>) {
let func = |x, y| async move { Ok(x + y) };
let rfn = rfn::RFn::new_2(func);
tx.send(rfn).await.unwrap();
}
Implementations§
source§impl<R, Codec> RFn<(), R, Codec>where
R: RemoteSend,
Codec: Codec,
impl<R, Codec> RFn<(), R, Codec>where
R: RemoteSend,
Codec: Codec,
sourcepub fn provided_0<F, Fut>(fun: F) -> (Self, RFnProvider)
pub fn provided_0<F, Fut>(fun: F) -> (Self, RFnProvider)
Create a new remote function and return it with its provider.
See the module-level documentation for details.
source§impl<A1, R, Codec> RFn<(A1,), R, Codec>
impl<A1, R, Codec> RFn<(A1,), R, Codec>
sourcepub fn provided_1<F, Fut>(fun: F) -> (Self, RFnProvider)
pub fn provided_1<F, Fut>(fun: F) -> (Self, RFnProvider)
Create a new remote function and return it with its provider.
See the module-level documentation for details.
source§impl<A1, A2, R, Codec> RFn<(A1, A2), R, Codec>
impl<A1, A2, R, Codec> RFn<(A1, A2), R, Codec>
sourcepub fn provided_2<F, Fut>(fun: F) -> (Self, RFnProvider)
pub fn provided_2<F, Fut>(fun: F) -> (Self, RFnProvider)
Create a new remote function and return it with its provider.
See the module-level documentation for details.
source§impl<A1, A2, RT, RE, Codec> RFn<(A1, A2), Result<RT, RE>, Codec>where
A1: RemoteSend,
A2: RemoteSend,
RT: RemoteSend,
RE: RemoteSend + From<CallError>,
Codec: Codec,
impl<A1, A2, RT, RE, Codec> RFn<(A1, A2), Result<RT, RE>, Codec>where
A1: RemoteSend,
A2: RemoteSend,
RT: RemoteSend,
RE: RemoteSend + From<CallError>,
Codec: Codec,
source§impl<A1, A2, A3, R, Codec> RFn<(A1, A2, A3), R, Codec>
impl<A1, A2, A3, R, Codec> RFn<(A1, A2, A3), R, Codec>
sourcepub fn provided_3<F, Fut>(fun: F) -> (Self, RFnProvider)
pub fn provided_3<F, Fut>(fun: F) -> (Self, RFnProvider)
Create a new remote function and return it with its provider.
See the module-level documentation for details.
source§impl<A1, A2, A3, RT, RE, Codec> RFn<(A1, A2, A3), Result<RT, RE>, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
RT: RemoteSend,
RE: RemoteSend + From<CallError>,
Codec: Codec,
impl<A1, A2, A3, RT, RE, Codec> RFn<(A1, A2, A3), Result<RT, RE>, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
RT: RemoteSend,
RE: RemoteSend + From<CallError>,
Codec: Codec,
source§impl<A1, A2, A3, A4, R, Codec> RFn<(A1, A2, A3, A4), R, Codec>
impl<A1, A2, A3, A4, R, Codec> RFn<(A1, A2, A3, A4), R, Codec>
sourcepub fn provided_4<F, Fut>(fun: F) -> (Self, RFnProvider)
pub fn provided_4<F, Fut>(fun: F) -> (Self, RFnProvider)
Create a new remote function and return it with its provider.
See the module-level documentation for details.
source§impl<A1, A2, A3, A4, RT, RE, Codec> RFn<(A1, A2, A3, A4), Result<RT, RE>, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
RT: RemoteSend,
RE: RemoteSend + From<CallError>,
Codec: Codec,
impl<A1, A2, A3, A4, RT, RE, Codec> RFn<(A1, A2, A3, A4), Result<RT, RE>, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
RT: RemoteSend,
RE: RemoteSend + From<CallError>,
Codec: Codec,
source§impl<A1, A2, A3, A4, A5, R, Codec> RFn<(A1, A2, A3, A4, A5), R, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
R: RemoteSend,
Codec: Codec,
impl<A1, A2, A3, A4, A5, R, Codec> RFn<(A1, A2, A3, A4, A5), R, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
R: RemoteSend,
Codec: Codec,
sourcepub fn provided_5<F, Fut>(fun: F) -> (Self, RFnProvider)
pub fn provided_5<F, Fut>(fun: F) -> (Self, RFnProvider)
Create a new remote function and return it with its provider.
See the module-level documentation for details.
source§impl<A1, A2, A3, A4, A5, RT, RE, Codec> RFn<(A1, A2, A3, A4, A5), Result<RT, RE>, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
RT: RemoteSend,
RE: RemoteSend + From<CallError>,
Codec: Codec,
impl<A1, A2, A3, A4, A5, RT, RE, Codec> RFn<(A1, A2, A3, A4, A5), Result<RT, RE>, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
RT: RemoteSend,
RE: RemoteSend + From<CallError>,
Codec: Codec,
source§impl<A1, A2, A3, A4, A5, A6, R, Codec> RFn<(A1, A2, A3, A4, A5, A6), R, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
R: RemoteSend,
Codec: Codec,
impl<A1, A2, A3, A4, A5, A6, R, Codec> RFn<(A1, A2, A3, A4, A5, A6), R, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
R: RemoteSend,
Codec: Codec,
sourcepub fn provided_6<F, Fut>(fun: F) -> (Self, RFnProvider)
pub fn provided_6<F, Fut>(fun: F) -> (Self, RFnProvider)
Create a new remote function and return it with its provider.
See the module-level documentation for details.
source§impl<A1, A2, A3, A4, A5, A6, RT, RE, Codec> RFn<(A1, A2, A3, A4, A5, A6), Result<RT, RE>, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
RT: RemoteSend,
RE: RemoteSend + From<CallError>,
Codec: Codec,
impl<A1, A2, A3, A4, A5, A6, RT, RE, Codec> RFn<(A1, A2, A3, A4, A5, A6), Result<RT, RE>, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
RT: RemoteSend,
RE: RemoteSend + From<CallError>,
Codec: Codec,
source§impl<A1, A2, A3, A4, A5, A6, A7, R, Codec> RFn<(A1, A2, A3, A4, A5, A6, A7), R, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
A7: RemoteSend,
R: RemoteSend,
Codec: Codec,
impl<A1, A2, A3, A4, A5, A6, A7, R, Codec> RFn<(A1, A2, A3, A4, A5, A6, A7), R, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
A7: RemoteSend,
R: RemoteSend,
Codec: Codec,
sourcepub fn provided_7<F, Fut>(fun: F) -> (Self, RFnProvider)
pub fn provided_7<F, Fut>(fun: F) -> (Self, RFnProvider)
Create a new remote function and return it with its provider.
See the module-level documentation for details.
source§impl<A1, A2, A3, A4, A5, A6, A7, RT, RE, Codec> RFn<(A1, A2, A3, A4, A5, A6, A7), Result<RT, RE>, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
A7: RemoteSend,
RT: RemoteSend,
RE: RemoteSend + From<CallError>,
Codec: Codec,
impl<A1, A2, A3, A4, A5, A6, A7, RT, RE, Codec> RFn<(A1, A2, A3, A4, A5, A6, A7), Result<RT, RE>, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
A7: RemoteSend,
RT: RemoteSend,
RE: RemoteSend + From<CallError>,
Codec: Codec,
source§impl<A1, A2, A3, A4, A5, A6, A7, A8, R, Codec> RFn<(A1, A2, A3, A4, A5, A6, A7, A8), R, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
A7: RemoteSend,
A8: RemoteSend,
R: RemoteSend,
Codec: Codec,
impl<A1, A2, A3, A4, A5, A6, A7, A8, R, Codec> RFn<(A1, A2, A3, A4, A5, A6, A7, A8), R, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
A7: RemoteSend,
A8: RemoteSend,
R: RemoteSend,
Codec: Codec,
sourcepub fn provided_8<F, Fut>(fun: F) -> (Self, RFnProvider)
pub fn provided_8<F, Fut>(fun: F) -> (Self, RFnProvider)
Create a new remote function and return it with its provider.
See the module-level documentation for details.
source§impl<A1, A2, A3, A4, A5, A6, A7, A8, RT, RE, Codec> RFn<(A1, A2, A3, A4, A5, A6, A7, A8), Result<RT, RE>, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
A7: RemoteSend,
A8: RemoteSend,
RT: RemoteSend,
RE: RemoteSend + From<CallError>,
Codec: Codec,
impl<A1, A2, A3, A4, A5, A6, A7, A8, RT, RE, Codec> RFn<(A1, A2, A3, A4, A5, A6, A7, A8), Result<RT, RE>, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
A7: RemoteSend,
A8: RemoteSend,
RT: RemoteSend,
RE: RemoteSend + From<CallError>,
Codec: Codec,
source§impl<A1, A2, A3, A4, A5, A6, A7, A8, A9, R, Codec> RFn<(A1, A2, A3, A4, A5, A6, A7, A8, A9), R, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
A7: RemoteSend,
A8: RemoteSend,
A9: RemoteSend,
R: RemoteSend,
Codec: Codec,
impl<A1, A2, A3, A4, A5, A6, A7, A8, A9, R, Codec> RFn<(A1, A2, A3, A4, A5, A6, A7, A8, A9), R, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
A7: RemoteSend,
A8: RemoteSend,
A9: RemoteSend,
R: RemoteSend,
Codec: Codec,
sourcepub fn provided_9<F, Fut>(fun: F) -> (Self, RFnProvider)
pub fn provided_9<F, Fut>(fun: F) -> (Self, RFnProvider)
Create a new remote function and return it with its provider.
See the module-level documentation for details.
source§impl<A1, A2, A3, A4, A5, A6, A7, A8, A9, RT, RE, Codec> RFn<(A1, A2, A3, A4, A5, A6, A7, A8, A9), Result<RT, RE>, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
A7: RemoteSend,
A8: RemoteSend,
A9: RemoteSend,
RT: RemoteSend,
RE: RemoteSend + From<CallError>,
Codec: Codec,
impl<A1, A2, A3, A4, A5, A6, A7, A8, A9, RT, RE, Codec> RFn<(A1, A2, A3, A4, A5, A6, A7, A8, A9), Result<RT, RE>, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
A7: RemoteSend,
A8: RemoteSend,
A9: RemoteSend,
RT: RemoteSend,
RE: RemoteSend + From<CallError>,
Codec: Codec,
source§impl<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, R, Codec> RFn<(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10), R, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
A7: RemoteSend,
A8: RemoteSend,
A9: RemoteSend,
A10: RemoteSend,
R: RemoteSend,
Codec: Codec,
impl<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, R, Codec> RFn<(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10), R, Codec>where
A1: RemoteSend,
A2: RemoteSend,
A3: RemoteSend,
A4: RemoteSend,
A5: RemoteSend,
A6: RemoteSend,
A7: RemoteSend,
A8: RemoteSend,
A9: RemoteSend,
A10: RemoteSend,
R: RemoteSend,
Codec: Codec,
sourcepub fn provided_10<F, Fut>(fun: F) -> (Self, RFnProvider)
pub fn provided_10<F, Fut>(fun: F) -> (Self, RFnProvider)
Create a new remote function and return it with its provider.
See the module-level documentation for details.