StreamingAdapter

Trait StreamingAdapter 

Source
pub trait StreamingAdapter: Send + Sync {
    type Request;
    type Response;
    type Error: Error + Send + Sync + 'static;
    type StreamingResponseFuture<'a>: Future<Output = IntegrationResult<Self::Response>> + Send + 'a
       where Self: 'a;
    type SseResponseFuture<'a>: Future<Output = IntegrationResult<Self::Response>> + Send + 'a
       where Self: 'a;
    type JsonResponseFuture<'a>: Future<Output = IntegrationResult<Self::Response>> + Send + 'a
       where Self: 'a;
    type MiddlewareFuture<'a>: Future<Output = IntegrationResult<UniversalResponse>> + Send + 'a
       where Self: 'a;

    // Required methods
    fn convert_request(
        &self,
        request: Self::Request,
    ) -> IntegrationResult<UniversalRequest>;
    fn to_response(
        &self,
        response: UniversalResponse,
    ) -> IntegrationResult<Self::Response>;
    fn create_streaming_response<'a>(
        &'a self,
        session_id: SessionId,
        frames: Vec<StreamFrame>,
        format: StreamingFormat,
    ) -> Self::StreamingResponseFuture<'a>;
    fn create_sse_response<'a>(
        &'a self,
        session_id: SessionId,
        frames: Vec<StreamFrame>,
    ) -> Self::SseResponseFuture<'a>;
    fn create_json_response<'a>(
        &'a self,
        data: JsonData,
        streaming: bool,
    ) -> Self::JsonResponseFuture<'a>;
    fn apply_middleware<'a>(
        &'a self,
        request: &'a UniversalRequest,
        response: UniversalResponse,
    ) -> Self::MiddlewareFuture<'a>;
    fn framework_name(&self) -> &'static str;

    // Provided methods
    fn supports_streaming(&self) -> bool { ... }
    fn supports_sse(&self) -> bool { ... }
}
Expand description

High-performance streaming adapter using GAT zero-cost abstractions

This trait provides zero-cost abstractions for web framework integration using impl Trait in associated types (requires nightly Rust).

§Performance Benefits

  • 1.82x faster trait dispatch vs async_trait
  • Zero heap allocations for futures
  • Pure stack allocation with static dispatch
  • Complete inlining for hot paths

Required Associated Types§

Source

type Request

The framework’s native request type

Source

type Response

The framework’s native response type

Source

type Error: Error + Send + Sync + 'static

The framework’s error type

Source

type StreamingResponseFuture<'a>: Future<Output = IntegrationResult<Self::Response>> + Send + 'a where Self: 'a

Source

type SseResponseFuture<'a>: Future<Output = IntegrationResult<Self::Response>> + Send + 'a where Self: 'a

Source

type JsonResponseFuture<'a>: Future<Output = IntegrationResult<Self::Response>> + Send + 'a where Self: 'a

Source

type MiddlewareFuture<'a>: Future<Output = IntegrationResult<UniversalResponse>> + Send + 'a where Self: 'a

Required Methods§

Source

fn convert_request( &self, request: Self::Request, ) -> IntegrationResult<UniversalRequest>

Convert framework request to universal format

Source

fn to_response( &self, response: UniversalResponse, ) -> IntegrationResult<Self::Response>

Convert universal response to framework format

Source

fn create_streaming_response<'a>( &'a self, session_id: SessionId, frames: Vec<StreamFrame>, format: StreamingFormat, ) -> Self::StreamingResponseFuture<'a>

Create a streaming response with priority-based frame delivery

Source

fn create_sse_response<'a>( &'a self, session_id: SessionId, frames: Vec<StreamFrame>, ) -> Self::SseResponseFuture<'a>

Create a Server-Sent Events response with SIMD acceleration

Source

fn create_json_response<'a>( &'a self, data: JsonData, streaming: bool, ) -> Self::JsonResponseFuture<'a>

Create a JSON response with optional streaming

Source

fn apply_middleware<'a>( &'a self, request: &'a UniversalRequest, response: UniversalResponse, ) -> Self::MiddlewareFuture<'a>

Handle framework-specific middleware integration

Source

fn framework_name(&self) -> &'static str

Get the framework name for debugging/logging

Provided Methods§

Source

fn supports_streaming(&self) -> bool

Check if the framework supports streaming

Source

fn supports_sse(&self) -> bool

Check if the framework supports Server-Sent Events

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Req, Res, Err> StreamingAdapter for UniversalAdapter<Req, Res, Err>
where Req: Send + Sync + 'static, Res: Send + Sync + 'static, Err: Error + Send + Sync + 'static,

Source§

type Request = Req

Source§

type Response = Res

Source§

type Error = Err

Source§

type StreamingResponseFuture<'a> = impl Future<Output = Result<<UniversalAdapter<Req, Res, Err> as StreamingAdapter>::Response, IntegrationError>> + Send + 'a where Self: 'a

Source§

type SseResponseFuture<'a> = impl Future<Output = Result<<UniversalAdapter<Req, Res, Err> as StreamingAdapter>::Response, IntegrationError>> + Send + 'a where Self: 'a

Source§

type JsonResponseFuture<'a> = impl Future<Output = Result<<UniversalAdapter<Req, Res, Err> as StreamingAdapter>::Response, IntegrationError>> + Send + 'a where Self: 'a

Source§

type MiddlewareFuture<'a> = impl Future<Output = Result<UniversalResponse, IntegrationError>> + Send + 'a where Self: 'a