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§
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§
Sourcefn convert_request(
&self,
request: Self::Request,
) -> IntegrationResult<UniversalRequest>
fn convert_request( &self, request: Self::Request, ) -> IntegrationResult<UniversalRequest>
Convert framework request to universal format
Sourcefn to_response(
&self,
response: UniversalResponse,
) -> IntegrationResult<Self::Response>
fn to_response( &self, response: UniversalResponse, ) -> IntegrationResult<Self::Response>
Convert universal response to framework format
Sourcefn create_streaming_response<'a>(
&'a self,
session_id: SessionId,
frames: Vec<StreamFrame>,
format: StreamingFormat,
) -> Self::StreamingResponseFuture<'a>
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
Sourcefn create_sse_response<'a>(
&'a self,
session_id: SessionId,
frames: Vec<StreamFrame>,
) -> Self::SseResponseFuture<'a>
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
Sourcefn create_json_response<'a>(
&'a self,
data: JsonData,
streaming: bool,
) -> Self::JsonResponseFuture<'a>
fn create_json_response<'a>( &'a self, data: JsonData, streaming: bool, ) -> Self::JsonResponseFuture<'a>
Create a JSON response with optional streaming
Sourcefn apply_middleware<'a>(
&'a self,
request: &'a UniversalRequest,
response: UniversalResponse,
) -> Self::MiddlewareFuture<'a>
fn apply_middleware<'a>( &'a self, request: &'a UniversalRequest, response: UniversalResponse, ) -> Self::MiddlewareFuture<'a>
Handle framework-specific middleware integration
Sourcefn framework_name(&self) -> &'static str
fn framework_name(&self) -> &'static str
Get the framework name for debugging/logging
Provided Methods§
Sourcefn supports_streaming(&self) -> bool
fn supports_streaming(&self) -> bool
Check if the framework supports streaming
Sourcefn supports_sse(&self) -> bool
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.