pub struct Rpc<Input, Output> { /* private fields */ }Expand description
Names one typed RPC exposed by a Flow.
Use the same value when binding the handler in RpcList and invoking it through
crate::Client. Input and output types must implement Value. The stable name becomes part
of the protocol and must remain compatible with running Flows.
§Examples
use dex_sdk::{Context, Flow, HandlerResult, Rpc, RpcList, RpcResult};
const STATUS: Rpc<(), String> = Rpc::new("status");
struct OrderFlow;
impl OrderFlow {
fn status(&self, _context: &mut Context) -> HandlerResult<RpcResult<String>> {
Ok(RpcResult::new("ready".to_owned()))
}
}
impl Flow for OrderFlow {
type StartInput = ();
fn rpcs(&self) -> RpcList<Self> {
RpcList::new().function_without_input(STATUS, Self::status)
}
}Implementations§
Source§impl<Input, Output> Rpc<Input, Output>
impl<Input, Output> Rpc<Input, Output>
Sourcepub const fn new(name: &'static str) -> Self
pub const fn new(name: &'static str) -> Self
Defines an RPC with a stable protocol name and no option overrides.
Sourcepub fn timeout(self, timeout: Duration) -> RpcDefinition<Input, Output>
pub fn timeout(self, timeout: Duration) -> RpcDefinition<Input, Output>
Converts this RPC into a definition with a handler execution timeout.
Sourcepub fn lock(self, lock: AttributeLock) -> RpcDefinition<Input, Output>
pub fn lock(self, lock: AttributeLock) -> RpcDefinition<Input, Output>
Converts this RPC into a definition holding one Attribute lock during invocation.
Trait Implementations§
impl<Input, Output> Copy for Rpc<Input, Output>
Auto Trait Implementations§
impl<Input, Output> Freeze for Rpc<Input, Output>
impl<Input, Output> RefUnwindSafe for Rpc<Input, Output>
impl<Input, Output> Send for Rpc<Input, Output>
impl<Input, Output> Sync for Rpc<Input, Output>
impl<Input, Output> Unpin for Rpc<Input, Output>
impl<Input, Output> UnsafeUnpin for Rpc<Input, Output>
impl<Input, Output> UnwindSafe for Rpc<Input, Output>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request