pub struct EncryptedQueryBuilder<T> { /* private fields */ }Expand description
Route builder that expects VEIL-encrypted URL query parameters of type T.
Obtained from ServerMechanism::encrypted_query. The client must send a single
?data=<base64url> query parameter whose value is the URL-safe base64 encoding of
the VEIL-encrypted struct bytes. On each matching request the server base64-decodes
then decrypts the value using the configured SerializationKey. If any step fails
(missing data parameter, invalid base64, wrong key, corrupt bytes) the route
returns 403 Forbidden — the handler is never invoked.
Optionally attach shared state via state before
finalising with onconnect.
Implementations§
Source§impl<T> EncryptedQueryBuilder<T>
impl<T> EncryptedQueryBuilder<T>
Sourcepub fn onconnect<F, Fut, Re>(self, handler: F) -> SocketType
pub fn onconnect<F, Fut, Re>(self, handler: F) -> SocketType
Finalises this route with an async handler that receives the decrypted query
parameters as T.
On each request the ?data=<base64url> query parameter is base64-decoded then
VEIL-decrypted using the SerializationKey on this builder. The handler is only
invoked when every step succeeds — a missing data parameter, invalid base64,
wrong key, or corrupt payload causes the route to return 403 Forbidden without
ever reaching the handler. The T the closure receives is therefore always a
trusted, fully-decrypted value ready to use.
The handler must return Result<impl Reply, Rejection>.
Returns a SocketType ready to be passed to Server::mechanism.
Sourcepub fn state<S: Clone + Send + Sync + 'static>(
self,
state: S,
) -> StatefulEncryptedQueryBuilder<T, S>
pub fn state<S: Clone + Send + Sync + 'static>( self, state: S, ) -> StatefulEncryptedQueryBuilder<T, S>
Attaches shared state S, transitioning to StatefulEncryptedQueryBuilder.
A fresh clone of S is injected alongside the decrypted T on every request.
The handler will receive (state: S, query: T).
S must be Clone + Send + Sync + 'static.