You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`ConnectHandlerWrapper<F>`| Unified: unary, server/client/bidi streaming with optional extractors |
125
122
|`TonicCompatibleHandlerWrapper<F>`| Tonic-style unary with axum extractors |
126
123
|`TonicCompatibleStreamHandlerWrapper<F>`| Tonic-style server streaming with axum extractors |
127
124
|`TonicCompatibleClientStreamHandlerWrapper<F>`| Tonic-style client streaming with axum extractors |
128
125
|`TonicCompatibleBidiStreamHandlerWrapper<F>`| Tonic-style bidi streaming with axum extractors |
129
126
127
+
### Handler Functions
128
+
129
+
Two functions create method routers from handlers:
130
+
131
+
| Function | HTTP Method | Use Case |
132
+
|----------|-------------|----------|
133
+
|`post_connect(f)`| POST | Unary and streaming RPCs |
134
+
|`get_connect(f)`| GET | Idempotent unary RPCs (query param encoding) |
135
+
130
136
### How Handler Wrappers Work
131
137
132
-
`ConnectHandlerWrapper<F>` is a newtype that wraps a user function `F`. It has multiple `impl Handler<T, S>` blocks, each with different `where` bounds on `F`:
138
+
`ConnectHandlerWrapper<F>` is a newtype that wraps a user function `F`. It has multiple `impl Handler<T, S>` blocks, each with different `where` bounds on `F`. The compiler selects the appropriate impl based on the handler signature:
// With extractors: (State<T>, ConnectRequest<Streaming<Req>>) -> ConnectResponse<StreamBody<St>>
144
162
```
145
163
146
-
The compiler inspects `F`'s signature (input types + return type) and selects the impl whose `where` bounds match. The `T` parameter in `Handler<T, S>` acts as a discriminator tag - it's not used at runtime, only for impl selection.
164
+
The `T` parameter in `Handler<T, S>` acts as a discriminator tag for impl selection. Separate macro-generated implementations handle extractors for each streaming pattern.
0 commit comments