pub struct ConnectionHandle(/* private fields */);Expand description
Defines a connection to a Norgopolis instance.
Implementations§
Source§impl ConnectionHandle
impl ConnectionHandle
Sourcepub fn invoke_raw(
&mut self,
module: String,
function_name: String,
args: Option<MessagePack>,
) -> impl Future<Output = Result<Response<Streaming<MessagePack>>, Status>> + '_
pub fn invoke_raw( &mut self, module: String, function_name: String, args: Option<MessagePack>, ) -> impl Future<Output = Result<Response<Streaming<MessagePack>>, Status>> + '_
Invokes a function of a given module running under Norgopolis. Returns a future to the response stream.
It’s recommended to use the non-raw functions if you do not need greater control over the data being sent.
Sourcepub async fn invoke_raw_callback<F>(
&mut self,
module: String,
function_name: String,
args: Option<MessagePack>,
callback: F,
) -> Result<()>where
F: Fn(MessagePack),
pub async fn invoke_raw_callback<F>(
&mut self,
module: String,
function_name: String,
args: Option<MessagePack>,
callback: F,
) -> Result<()>where
F: Fn(MessagePack),
Invokes a function of a given module running under Norgopolis.
On every received message a callback will be executed with the raw MessagePack return data.
It’s recommended to use the non-raw functions if you do not need greater control over the data being sent.
Sourcepub async fn invoke<TargetStruct, F>(
&mut self,
module: String,
function_name: String,
args: Option<MessagePack>,
callback: F,
) -> Result<()>where
F: Fn(TargetStruct),
TargetStruct: DeserializeOwned,
pub async fn invoke<TargetStruct, F>(
&mut self,
module: String,
function_name: String,
args: Option<MessagePack>,
callback: F,
) -> Result<()>where
F: Fn(TargetStruct),
TargetStruct: DeserializeOwned,
High-level function to invoke a given module’s function.
Will execute a callback on every received return message, but will also automatically deserialize the received MessagePack into a struct of your choice.
Example:
// Automatically deserialize the MessagePack into a String.
connection.invoke("module-name".to_string(), "function-name".to_string(), None, |response: String| println!("{}", response))
.await
.unwrap();Sourcepub async fn invoke_collect<TargetStruct>(
&mut self,
module: String,
function_name: String,
args: Option<MessagePack>,
) -> Result<Vec<TargetStruct>>where
TargetStruct: DeserializeOwned,
pub async fn invoke_collect<TargetStruct>(
&mut self,
module: String,
function_name: String,
args: Option<MessagePack>,
) -> Result<Vec<TargetStruct>>where
TargetStruct: DeserializeOwned,
Invokes a function of a given module running under norgopolis.
Instead of streaming return values back over time, this function waits until all possible return values have been received and then returns a vector of outputs.
Auto Trait Implementations§
impl !Freeze for ConnectionHandle
impl !RefUnwindSafe for ConnectionHandle
impl Send for ConnectionHandle
impl Sync for ConnectionHandle
impl Unpin for ConnectionHandle
impl !UnwindSafe for ConnectionHandle
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> 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