Struct remoc::rfn::RFnMut

source ·
pub struct RFnMut<A, R, Codec = Default> { /* private fields */ }
Available on crate feature rfn only.
Expand description

Calls an async FnMut function possibly located on a remote endpoint.

The function can take between zero and ten arguments.

§Example

In the following example the server sends a remote function that sums numbers using an internal accumulator. The client receives the remote function and calls it three times.

use remoc::prelude::*;

type SumRFnMut = rfn::RFnMut<(u32,), Result<u32, rfn::CallError>>;

// This would be run on the client.
async fn client(mut rx: rch::base::Receiver<SumRFnMut>) {
    let mut rfn_mut = rx.recv().await.unwrap().unwrap();
    assert_eq!(rfn_mut.call(3).await.unwrap(), 3);
    assert_eq!(rfn_mut.call(2).await.unwrap(), 5);
    assert_eq!(rfn_mut.call(11).await.unwrap(), 16);
}

// This would be run on the server.
async fn server(mut tx: rch::base::Sender<SumRFnMut>) {
    let mut sum = 0;
    let func = move |x| {
        sum += x;
        async move { Ok(sum) }
    };
    let rfn_mut = rfn::RFnMut::new_1(func);
    tx.send(rfn_mut).await.unwrap();
}

Implementations§

source§

impl<R, Codec> RFnMut<(), R, Codec>
where R: RemoteSend, Codec: Codec,

source

pub fn new_0<F, Fut>(fun: F) -> Self
where F: FnMut() -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function.

source

pub fn provided_0<F, Fut>(fun: F) -> (Self, RFnMutProvider)
where F: FnMut() -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function and return it with its provider.

See the module-level documentation for details.

source

pub async fn try_call(&mut self) -> Result<R, CallError>

Try to call the remote function.

source§

impl<RT, RE, Codec> RFnMut<(), Result<RT, RE>, Codec>
where RT: RemoteSend, RE: RemoteSend + From<CallError>, Codec: Codec,

source

pub async fn call(&mut self) -> Result<RT, RE>

Call the remote function.

The CallError type must be convertible to the functions error type.

source§

impl<A1, R, Codec> RFnMut<(A1,), R, Codec>
where A1: RemoteSend, R: RemoteSend, Codec: Codec,

source

pub fn new_1<F, Fut>(fun: F) -> Self
where F: FnMut(A1) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function.

source

pub fn provided_1<F, Fut>(fun: F) -> (Self, RFnMutProvider)
where F: FnMut(A1) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function and return it with its provider.

See the module-level documentation for details.

source

pub async fn try_call(&mut self, arg1: A1) -> Result<R, CallError>

Try to call the remote function.

source§

impl<A1, RT, RE, Codec> RFnMut<(A1,), Result<RT, RE>, Codec>
where A1: RemoteSend, RT: RemoteSend, RE: RemoteSend + From<CallError>, Codec: Codec,

source

pub async fn call(&mut self, arg1: A1) -> Result<RT, RE>

Call the remote function.

The CallError type must be convertible to the functions error type.

source§

impl<A1, A2, R, Codec> RFnMut<(A1, A2), R, Codec>
where A1: RemoteSend, A2: RemoteSend, R: RemoteSend, Codec: Codec,

source

pub fn new_2<F, Fut>(fun: F) -> Self
where F: FnMut(A1, A2) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function.

source

pub fn provided_2<F, Fut>(fun: F) -> (Self, RFnMutProvider)
where F: FnMut(A1, A2) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function and return it with its provider.

See the module-level documentation for details.

source

pub async fn try_call(&mut self, arg1: A1, arg2: A2) -> Result<R, CallError>

Try to call the remote function.

source§

impl<A1, A2, RT, RE, Codec> RFnMut<(A1, A2), Result<RT, RE>, Codec>
where A1: RemoteSend, A2: RemoteSend, RT: RemoteSend, RE: RemoteSend + From<CallError>, Codec: Codec,

source

pub async fn call(&mut self, arg1: A1, arg2: A2) -> Result<RT, RE>

Call the remote function.

The CallError type must be convertible to the functions error type.

source§

impl<A1, A2, A3, R, Codec> RFnMut<(A1, A2, A3), R, Codec>
where A1: RemoteSend, A2: RemoteSend, A3: RemoteSend, R: RemoteSend, Codec: Codec,

source

pub fn new_3<F, Fut>(fun: F) -> Self
where F: FnMut(A1, A2, A3) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function.

source

pub fn provided_3<F, Fut>(fun: F) -> (Self, RFnMutProvider)
where F: FnMut(A1, A2, A3) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function and return it with its provider.

See the module-level documentation for details.

source

pub async fn try_call( &mut self, arg1: A1, arg2: A2, arg3: A3 ) -> Result<R, CallError>

Try to call the remote function.

source§

impl<A1, A2, A3, RT, RE, Codec> RFnMut<(A1, A2, A3), Result<RT, RE>, Codec>
where A1: RemoteSend, A2: RemoteSend, A3: RemoteSend, RT: RemoteSend, RE: RemoteSend + From<CallError>, Codec: Codec,

source

pub async fn call(&mut self, arg1: A1, arg2: A2, arg3: A3) -> Result<RT, RE>

Call the remote function.

The CallError type must be convertible to the functions error type.

source§

impl<A1, A2, A3, A4, R, Codec> RFnMut<(A1, A2, A3, A4), R, Codec>
where A1: RemoteSend, A2: RemoteSend, A3: RemoteSend, A4: RemoteSend, R: RemoteSend, Codec: Codec,

source

pub fn new_4<F, Fut>(fun: F) -> Self
where F: FnMut(A1, A2, A3, A4) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function.

source

pub fn provided_4<F, Fut>(fun: F) -> (Self, RFnMutProvider)
where F: FnMut(A1, A2, A3, A4) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function and return it with its provider.

See the module-level documentation for details.

source

pub async fn try_call( &mut self, arg1: A1, arg2: A2, arg3: A3, arg4: A4 ) -> Result<R, CallError>

Try to call the remote function.

source§

impl<A1, A2, A3, A4, RT, RE, Codec> RFnMut<(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

pub async fn call( &mut self, arg1: A1, arg2: A2, arg3: A3, arg4: A4 ) -> Result<RT, RE>

Call the remote function.

The CallError type must be convertible to the functions error type.

source§

impl<A1, A2, A3, A4, A5, R, Codec> RFnMut<(A1, A2, A3, A4, A5), R, Codec>
where A1: RemoteSend, A2: RemoteSend, A3: RemoteSend, A4: RemoteSend, A5: RemoteSend, R: RemoteSend, Codec: Codec,

source

pub fn new_5<F, Fut>(fun: F) -> Self
where F: FnMut(A1, A2, A3, A4, A5) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function.

source

pub fn provided_5<F, Fut>(fun: F) -> (Self, RFnMutProvider)
where F: FnMut(A1, A2, A3, A4, A5) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function and return it with its provider.

See the module-level documentation for details.

source

pub async fn try_call( &mut self, arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5 ) -> Result<R, CallError>

Try to call the remote function.

source§

impl<A1, A2, A3, A4, A5, RT, RE, Codec> RFnMut<(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

pub async fn call( &mut self, arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5 ) -> Result<RT, RE>

Call the remote function.

The CallError type must be convertible to the functions error type.

source§

impl<A1, A2, A3, A4, A5, A6, R, Codec> RFnMut<(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,

source

pub fn new_6<F, Fut>(fun: F) -> Self
where F: FnMut(A1, A2, A3, A4, A5, A6) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function.

source

pub fn provided_6<F, Fut>(fun: F) -> (Self, RFnMutProvider)
where F: FnMut(A1, A2, A3, A4, A5, A6) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function and return it with its provider.

See the module-level documentation for details.

source

pub async fn try_call( &mut self, arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, arg6: A6 ) -> Result<R, CallError>

Try to call the remote function.

source§

impl<A1, A2, A3, A4, A5, A6, RT, RE, Codec> RFnMut<(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

pub async fn call( &mut self, arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, arg6: A6 ) -> Result<RT, RE>

Call the remote function.

The CallError type must be convertible to the functions error type.

source§

impl<A1, A2, A3, A4, A5, A6, A7, R, Codec> RFnMut<(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,

source

pub fn new_7<F, Fut>(fun: F) -> Self
where F: FnMut(A1, A2, A3, A4, A5, A6, A7) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function.

source

pub fn provided_7<F, Fut>(fun: F) -> (Self, RFnMutProvider)
where F: FnMut(A1, A2, A3, A4, A5, A6, A7) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function and return it with its provider.

See the module-level documentation for details.

source

pub async fn try_call( &mut self, arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, arg6: A6, arg7: A7 ) -> Result<R, CallError>

Try to call the remote function.

source§

impl<A1, A2, A3, A4, A5, A6, A7, RT, RE, Codec> RFnMut<(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

pub async fn call( &mut self, arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, arg6: A6, arg7: A7 ) -> Result<RT, RE>

Call the remote function.

The CallError type must be convertible to the functions error type.

source§

impl<A1, A2, A3, A4, A5, A6, A7, A8, R, Codec> RFnMut<(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,

source

pub fn new_8<F, Fut>(fun: F) -> Self
where F: FnMut(A1, A2, A3, A4, A5, A6, A7, A8) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function.

source

pub fn provided_8<F, Fut>(fun: F) -> (Self, RFnMutProvider)
where F: FnMut(A1, A2, A3, A4, A5, A6, A7, A8) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function and return it with its provider.

See the module-level documentation for details.

source

pub async fn try_call( &mut self, arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, arg6: A6, arg7: A7, arg8: A8 ) -> Result<R, CallError>

Try to call the remote function.

source§

impl<A1, A2, A3, A4, A5, A6, A7, A8, RT, RE, Codec> RFnMut<(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

pub async fn call( &mut self, arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, arg6: A6, arg7: A7, arg8: A8 ) -> Result<RT, RE>

Call the remote function.

The CallError type must be convertible to the functions error type.

source§

impl<A1, A2, A3, A4, A5, A6, A7, A8, A9, R, Codec> RFnMut<(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,

source

pub fn new_9<F, Fut>(fun: F) -> Self
where F: FnMut(A1, A2, A3, A4, A5, A6, A7, A8, A9) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function.

source

pub fn provided_9<F, Fut>(fun: F) -> (Self, RFnMutProvider)
where F: FnMut(A1, A2, A3, A4, A5, A6, A7, A8, A9) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function and return it with its provider.

See the module-level documentation for details.

source

pub async fn try_call( &mut self, arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, arg6: A6, arg7: A7, arg8: A8, arg9: A9 ) -> Result<R, CallError>

Try to call the remote function.

source§

impl<A1, A2, A3, A4, A5, A6, A7, A8, A9, RT, RE, Codec> RFnMut<(A1, A2, A3, A4, A5, A6, A7, A8, A9), Result<RT, RE>, Codec>

source

pub async fn call( &mut self, arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, arg6: A6, arg7: A7, arg8: A8, arg9: A9 ) -> Result<RT, RE>

Call the remote function.

The CallError type must be convertible to the functions error type.

source§

impl<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, R, Codec> RFnMut<(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,

source

pub fn new_10<F, Fut>(fun: F) -> Self
where F: FnMut(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function.

source

pub fn provided_10<F, Fut>(fun: F) -> (Self, RFnMutProvider)
where F: FnMut(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send,

Create a new remote function and return it with its provider.

See the module-level documentation for details.

source

pub async fn try_call( &mut self, arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, arg6: A6, arg7: A7, arg8: A8, arg9: A9, arg10: A10 ) -> Result<R, CallError>

Try to call the remote function.

source§

impl<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, RT, RE, Codec> RFnMut<(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10), Result<RT, RE>, Codec>
where A1: RemoteSend, A2: RemoteSend, A3: RemoteSend, A4: RemoteSend, A5: RemoteSend, A6: RemoteSend, A7: RemoteSend, A8: RemoteSend, A9: RemoteSend, A10: RemoteSend, RT: RemoteSend, RE: RemoteSend + From<CallError>, Codec: Codec,

source

pub async fn call( &mut self, arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, arg6: A6, arg7: A7, arg8: A8, arg9: A9, arg10: A10 ) -> Result<RT, RE>

Call the remote function.

The CallError type must be convertible to the functions error type.

Trait Implementations§

source§

impl<A, R, Codec> Debug for RFnMut<A, R, Codec>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, A, R, Codec> Deserialize<'de> for RFnMut<A, R, Codec>
where A: RemoteSend, R: RemoteSend, Codec: Codec,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<A, R, Codec> Drop for RFnMut<A, R, Codec>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<A, R, Codec> Serialize for RFnMut<A, R, Codec>
where A: RemoteSend, R: RemoteSend, Codec: Codec,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<A, R, Codec> Freeze for RFnMut<A, R, Codec>

§

impl<A, R, Codec = Json> !RefUnwindSafe for RFnMut<A, R, Codec>

§

impl<A, R, Codec> Send for RFnMut<A, R, Codec>
where Codec: Send, A: Send, R: Send,

§

impl<A, R, Codec> Sync for RFnMut<A, R, Codec>
where Codec: Sync + Send, A: Send, R: Send,

§

impl<A, R, Codec> Unpin for RFnMut<A, R, Codec>
where Codec: Unpin,

§

impl<A, R, Codec = Json> !UnwindSafe for RFnMut<A, R, Codec>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> RemoteSend for T
where T: Send + Serialize + DeserializeOwned + 'static,