pub trait RSocket: Sync + Send {
// Required methods
fn metadata_push<'life0, 'async_trait>(
&'life0 self,
req: Payload,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn fire_and_forget<'life0, 'async_trait>(
&'life0 self,
req: Payload,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn request_response<'life0, 'async_trait>(
&'life0 self,
req: Payload,
) -> Pin<Box<dyn Future<Output = Result<Option<Payload>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn request_stream(&self, req: Payload) -> Flux<Result<Payload>>;
fn request_channel(
&self,
reqs: Flux<Result<Payload>>,
) -> Flux<Result<Payload>>;
}Expand description
A contract providing different interaction models for RSocket protocol.
RSocket trait is based on async_trait crate.
§Example
use rsocket_rust::prelude::*;
use rsocket_rust::{async_trait, stream, Result};
struct ExampleRSocket;
#[async_trait]
impl RSocket for ExampleRSocket {
async fn metadata_push(&self, req: Payload) -> Result<()> {
Ok(())
}
async fn fire_and_forget(&self, req: Payload) -> Result<()> {
Ok(())
}
async fn request_response(&self, req: Payload) -> Result<Option<Payload>> {
Ok(Some(Payload::builder().set_data_utf8("bingo").build()))
}
fn request_stream(&self, req: Payload) -> Flux<Result<Payload>> {
Box::pin(stream! {
for _ in 0..3 {
yield Ok(Payload::builder().set_data_utf8("next payload").build());
}
})
}
fn request_channel(&self, reqs: Flux<Result<Payload>>) -> Flux<Result<Payload>> {
reqs
}
}Required Methods§
Sourcefn metadata_push<'life0, 'async_trait>(
&'life0 self,
req: Payload,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn metadata_push<'life0, 'async_trait>(
&'life0 self,
req: Payload,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Metadata-Push interaction model of RSocket.
Sourcefn fire_and_forget<'life0, 'async_trait>(
&'life0 self,
req: Payload,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn fire_and_forget<'life0, 'async_trait>(
&'life0 self,
req: Payload,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Fire and Forget interaction model of RSocket.
Sourcefn request_response<'life0, 'async_trait>(
&'life0 self,
req: Payload,
) -> Pin<Box<dyn Future<Output = Result<Option<Payload>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn request_response<'life0, 'async_trait>(
&'life0 self,
req: Payload,
) -> Pin<Box<dyn Future<Output = Result<Option<Payload>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Request-Response interaction model of RSocket.