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.
Sourcepub fn is_transactional(self) -> RpcDefinition<Input, Output>
pub fn is_transactional(self) -> RpcDefinition<Input, Output>
Requests transactional reads and writes for this RPC.
Sourcepub fn load_attribute_map<T>(
self,
attribute_map: &AttributeMap<T>,
) -> RpcDefinition<Input, Output>
pub fn load_attribute_map<T>( self, attribute_map: &AttributeMap<T>, ) -> RpcDefinition<Input, Output>
Converts this RPC into a definition that loads every current AttributeMap instance.
Sourcepub fn load_attribute_map_instance(
self,
load: AttributeMapLoad,
) -> RpcDefinition<Input, Output>
pub fn load_attribute_map_instance( self, load: AttributeMapLoad, ) -> RpcDefinition<Input, Output>
Converts this RPC into a definition that loads one AttributeMap instance.
Sourcepub fn load_channel<T>(
self,
channel: &Channel<T>,
) -> RpcDefinition<Input, Output>
pub fn load_channel<T>( self, channel: &Channel<T>, ) -> RpcDefinition<Input, Output>
Converts this RPC into a definition that loads one singleton Channel’s messages.
Sourcepub fn load_channel_map<T>(
self,
channel_map: &ChannelMap<T>,
) -> RpcDefinition<Input, Output>
pub fn load_channel_map<T>( self, channel_map: &ChannelMap<T>, ) -> RpcDefinition<Input, Output>
Converts this RPC into a definition that loads every current ChannelMap instance.
Sourcepub fn load_channel_map_instance(
self,
load: ChannelMapLoad,
) -> RpcDefinition<Input, Output>
pub fn load_channel_map_instance( self, load: ChannelMapLoad, ) -> RpcDefinition<Input, Output>
Converts this RPC into a definition that loads one ChannelMap instance.
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
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>
T in a tonic::Request