Skip to main content

Module codec

Module codec 

Source
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:

  1. IntoReq: The client serializes the ServerFn argument type into an HTTP request.
  2. The Client sends the request to the server.
  3. FromReq: The server deserializes the HTTP request back into the ServerFn type.
  4. The server calls ServerFn::run_body on the data.
  5. IntoRes: The server serializes the ServerFn::Output type into an HTTP response.
  6. The server integration applies any middleware from ServerFn::middlewares and responds to the request.
  7. FromRes: The client deserializes the response back into the ServerFn::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§

BitcodeEncoding
Serializes and deserializes with bitcode.
BitcodeSerdeEncoding
Serializes and deserializes with bitcode’s serde integration.
ByteStream
A stream of bytes.
CborEncoding
Serializes and deserializes CBOR with ciborium.
DeleteUrl
Pass arguments as the URL-encoded query string of a DELETE request. Note: Browser support for DELETE requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
GetUrl
Pass arguments as a URL-encoded query string of a GET request.
JsonEncoding
Serializes and deserializes JSON with serde_json.
MsgPackEncoding
Serializes and deserializes MessagePack with rmp_serde.
MultipartFormData
Encodes multipart form data.
Patch
A codec that encodes the data in the patch body
PatchUrl
Pass arguments as the URL-encoded body of a PATCH request. Note: Browser support for PATCH requests without JS/WASM may be poor. Consider using a POST 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.
PostcardEncoding
A codec for Postcard.
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 for PUT requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
RkyvEncoding
Pass arguments and receive responses using rkyv in a POST request.
SerdeLiteEncoding
Pass arguments and receive responses as JSON in the body of a POST request.
Streaming
An encoding that represents a stream of bytes.
StreamingText
An encoding that represents a stream of text.
TextStream
A stream of text.

Enums§

MultipartData
Describes whether the multipart data is on the client side or the server side.

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§

Bitcode
Pass arguments and receive responses using bitcode in a POST request.
BitcodeSerde
Pass arguments and receive responses using bitcode’s serde integration in a POST request.
Cbor
Pass arguments and receive responses using cbor in a POST request.
Json
Pass arguments and receive responses as JSON in the body of a POST request.
MsgPack
Pass arguments and receive responses as MessagePack in a POST request.
PatchBitcode
Pass arguments and receive responses using bitcode in the body of a PATCH request. Note: Browser support for PATCH requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
PatchBitcodeSerde
Pass arguments and receive responses using bitcode’s serde integration in the body of a PATCH request. Note: Browser support for PATCH requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
PatchCbor
Pass arguments and receive responses using cbor in the body of a PATCH request. Note: Browser support for PATCH requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
PatchJson
Pass arguments and receive responses as JSON in the body of a PATCH request. Note: Browser support for PATCH requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
PatchMsgPack
Pass arguments and receive responses as MessagePack in the body of a PATCH request. Note: Browser support for PATCH requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
PatchPostcard
Pass arguments and receive responses with postcard in a PATCH request. Note: Browser support for PATCH requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
PatchRkyv
Pass arguments and receive responses as rkyv in a PATCH request. Note: Browser support for PATCH requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
PatchSerdeLite
Pass arguments and receive responses as JSON in the body of a PATCH request. Note: Browser support for PATCH requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
Postcard
Pass arguments and receive responses with postcard in a POST request.
PutBitcode
Pass arguments and receive responses using bitcode in the body of a PUT request. Note: Browser support for PUT requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
PutBitcodeSerde
Pass arguments and receive responses using bitcode’s serde integration in the body of a PUT request. Note: Browser support for PUT requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
PutCbor
Pass arguments and receive responses using cbor in the body of a PUT request. Note: Browser support for PUT requests without JS/WASM may be poor. Consider using a POST 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 for PUT requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
PutMsgPack
Pass arguments and receive responses as MessagePack in the body of a PUT request. Note: Browser support for PUT requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
PutPostcard
Pass arguments and receive responses with postcard in a PUT request. Note: Browser support for PUT requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
PutRkyv
Pass arguments and receive responses as rkyv in a PUT request. Note: Browser support for PUT requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
PutSerdeLite
Pass arguments and receive responses as JSON in the body of a PUT request. Note: Browser support for PUT requests without JS/WASM may be poor. Consider using a POST request if functionality without JS/WASM is required.
Rkyv
Pass arguments and receive responses as rkyv in a POST request.
SerdeLite
Pass arguments and receive responses as JSON in the body of a POST request.