Module codec
Expand description
Encodings for arguments and results. The serialization/deserialization process for server functions consists of a series of steps, each of which is represented by a different trait:
IntoReq
: The client serializes theServerFn
argument type into an HTTP request.- The
Client
sends the request to the server. FromReq
: The server deserializes the HTTP request back into theServerFn
type.- The server calls
ServerFn::run_body
on the data. IntoRes
: The server serializes theServerFn::Output
type into an HTTP response.- The server integration applies any middleware from
ServerFn::middlewares
and responds to the request. FromRes
: The client deserializes the response back into theServerFn::Output
type.
Rather than a limited number of encodings, this crate allows you to define server functions that
mix and match the input encoding and output encoding. To define a new encoding, you simply implement
an input combination (IntoReq
and FromReq
) and/or an output encoding (IntoRes
and FromRes
).
This genuinely is an and/or: while some encodings can be used for both input and output (Json
, Cbor
, Rkyv
),
others can only be used for input (GetUrl
, MultipartData
).
Structs§
- Byte
Stream - A stream of bytes.
- Delete
Url - Pass arguments as the URL-encoded body of a
DELETE
request. Note: Browser support forDELETE
requests without JS/WASM may be poor. Consider using aPOST
request if functionality without JS/WASM is required. - GetUrl
- Pass arguments as a URL-encoded query string of a
GET
request. - Json
Encoding - Serializes and deserializes JSON with
serde_json
. - Patch
- A codec that encodes the data in the patch body
- Patch
Url - Pass arguments as the URL-encoded body of a
PATCH
request. Note: Browser support forPATCH
requests without JS/WASM may be poor. Consider using aPOST
request if functionality without JS/WASM is required. - Post
- A codec that encodes the data in the post body
- PostUrl
- Pass arguments as the URL-encoded body of a
POST
request. - Put
- A codec that encodes the data in the put body
- PutUrl
- Pass arguments as the URL-encoded body of a
PUT
request. Note: Browser support forPUT
requests without JS/WASM may be poor. Consider using aPOST
request if functionality without JS/WASM is required. - Streaming
- An encoding that represents a stream of bytes.
- Streaming
Text - An encoding that represents a stream of text.
- Text
Stream - A stream of text.
Traits§
- Encoding
- Defines a particular encoding format, which can be used for serializing or deserializing data.
- FromReq
- Deserializes an HTTP request into the data type, on the server.
- FromRes
- Deserializes the data type from an HTTP response.
- IntoReq
- Serializes a data type into an HTTP request, on the client.
- IntoRes
- Serializes the data type into an HTTP response.
Type Aliases§
- Json
- Pass arguments and receive responses as JSON in the body of a
POST
request. - Patch
Json - Pass arguments and receive responses as JSON in the body of a
PATCH
request. Note: Browser support forPATCH
requests without JS/WASM may be poor. Consider using aPOST
request if functionality without JS/WASM is required. - PutJson
- Pass arguments and receive responses as JSON in the body of a
PUT
request. Note: Browser support forPUT
requests without JS/WASM may be poor. Consider using aPOST
request if functionality without JS/WASM is required.