multipartkit/query
Values
pub fn field(
parts: List(part.Part),
name: String,
) -> option.Option(String)
Return the body of the first text field with the given name, decoded as
UTF-8.
A part counts as a text field iff its Content-Disposition is
form-data with a name parameter and no filename parameter.
Parts whose name is None are skipped.
If the first matching text field exists but its body is not valid UTF-8,
None is returned. Use required_field if you need to distinguish
“missing” from “present but not UTF-8”.
pub fn fields(
parts: List(part.Part),
name: String,
) -> List(String)
Return all text fields with the given name in input order. Parts whose
body is not valid UTF-8 are silently skipped. For strict semantics,
iterate manually with required_field.
pub fn file(
parts: List(part.Part),
name: String,
) -> option.Option(part.Part)
First file part with the given name. filename = Some("") still counts
as a file (the unselected <input type="file"> case).
pub fn files(
parts: List(part.Part),
name: String,
) -> List(part.Part)
All file parts with the given name in input order.
pub fn names(parts: List(part.Part)) -> List(String)
Distinct field names preserving first-appearance order. Parts with
name == None are skipped.
pub fn required_field(
parts: List(part.Part),
name: String,
) -> Result(String, error.MultipartError)
Strict variant of field. Returns MissingField if no text field
matches; returns InvalidUtf8Field if the body is not valid UTF-8.
pub fn required_file(
parts: List(part.Part),
name: String,
) -> Result(part.Part, error.MultipartError)
Strict variant of file. Returns MissingFile if no file part matches.