Module rocket::form[][src]

Expand description

Parsing and validation of HTTP forms and fields.

See the forms guide for general form support documentation.

Field Wire Format

Rocket’s field wire format is a flexible, non-self-descriptive, text-based encoding of arbitrarily nested structure keys and their corresponding values. The general grammar is:

field := name ('=' value)?

name := key*

key := indices
      | '[' indices ']'
      | '.' indices

indices := index (':' index)*

index := STRING except ':', ']'

value := STRING

Each field name consists of any number of keys and at most one value. Keys are delimited by [ or .. A key consists of indices delimited by :.

The meaning of a key or index is type-dependent, hence the format is non-self-descriptive. Any structure can be described by this format. The delimiters ., [, :, and ] have no semantic meaning.

Some examples of valid fields are:

  • =
  • key=value
  • key[]=value
  • .0=value
  • [0]=value
  • people[].name=Bob
  • bob.cousin.names[]=Bob
  • map[k:1]=Bob
  • people[bob]nickname=Stan

See FromForm for full details on push-parsing and complete examples.

Modules

Form error types.

Types for field names, name keys, and key indices.

Form field validation routines.

Structs

A form context containing received fields, values, and encountered errors.

An infallible form guard that records form fields and errors during parsing.

A multipart form field with an underlying data stream.

A form error, potentially tied to a specific form field.

A collection of Errors.

A data guard for FromForm types.

A form guard for parsing form types leniently.

Form guard options.

A form guard for parsing form types strictly.

A form field with a string value.

Traits

Trait implemented by form guards: types parseable from HTTP forms.

Implied form guard (FromForm) for parsing a single form field.

Type Definitions

Type alias for Result with an error type of Errors.