Trait rsocket_rust::prelude::RSocket[][src]

pub trait RSocket: Sync + Send {
    #[must_use]
    fn metadata_push<'life0, 'async_trait>(
        &'life0 self,
        req: Payload
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn fire_and_forget<'life0, 'async_trait>(
        &'life0 self,
        req: Payload
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn request_response<'life0, 'async_trait>(
        &'life0 self,
        req: Payload
    ) -> Pin<Box<dyn Future<Output = Result<Option<Payload>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: '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

#[must_use]
fn metadata_push<'life0, 'async_trait>(
    &'life0 self,
    req: Payload
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Expand description

Metadata-Push interaction model of RSocket.

#[must_use]
fn fire_and_forget<'life0, 'async_trait>(
    &'life0 self,
    req: Payload
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Expand description

Fire and Forget interaction model of RSocket.

#[must_use]
fn request_response<'life0, 'async_trait>(
    &'life0 self,
    req: Payload
) -> Pin<Box<dyn Future<Output = Result<Option<Payload>>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Expand description

Request-Response interaction model of RSocket.

fn request_stream(&self, req: Payload) -> Flux<Result<Payload>>[src]

Expand description

Request-Stream interaction model of RSocket.

fn request_channel(&self, reqs: Flux<Result<Payload>>) -> Flux<Result<Payload>>[src]

Expand description

Request-Channel interaction model of RSocket.

Loading content...

Implementors

impl RSocket for Client[src]

fn metadata_push<'life0, 'async_trait>(
    &'life0 self,
    req: Payload
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

fn fire_and_forget<'life0, 'async_trait>(
    &'life0 self,
    req: Payload
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

fn request_response<'life0, 'async_trait>(
    &'life0 self,
    req: Payload
) -> Pin<Box<dyn Future<Output = Result<Option<Payload>>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

fn request_stream(&self, req: Payload) -> Flux<Result<Payload>>[src]

fn request_channel(&self, reqs: Flux<Result<Payload>>) -> Flux<Result<Payload>>[src]

impl RSocket for EchoRSocket[src]

fn metadata_push<'life0, 'async_trait>(
    &'life0 self,
    req: Payload
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

fn fire_and_forget<'life0, 'async_trait>(
    &'life0 self,
    req: Payload
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

fn request_response<'life0, 'async_trait>(
    &'life0 self,
    req: Payload
) -> Pin<Box<dyn Future<Output = Result<Option<Payload>>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

fn request_stream(&self, req: Payload) -> Flux<Result<Payload>>[src]

fn request_channel(&self, reqs: Flux<Result<Payload>>) -> Flux<Result<Payload>>[src]

Loading content...