gossamer/form_data

Types

A set of key/value pairs representing form fields and their values, useful for building request bodies for multipart form submissions. Mutable — methods modify the set in place and return it for chaining.

See FormData on MDN.

pub type FormData

Represents a value stored in a FormData entry. Form data values are either strings or files.

pub type FormDataValue {
  Text(String)
  FileValue(file.File)
}

Constructors

Values

pub fn append(
  to form_data: FormData,
  name name: String,
  value value: String,
) -> FormData

Appends a new value onto an existing key, or adds the key if it does not already exist. Mutates the form data in-place and returns it for chaining.

pub fn append_blob(
  to form_data: FormData,
  name name: String,
  value value: blob.Blob,
) -> FormData

Appends a blob value. Mutates the form data in-place and returns it for chaining.

pub fn append_blob_with_filename(
  to form_data: FormData,
  name name: String,
  value value: blob.Blob,
  named filename: String,
) -> FormData

Appends a blob value with a filename. Mutates the form data in-place and returns it for chaining.

pub fn delete(
  from form_data: FormData,
  name name: String,
) -> FormData

Deletes a key and all its values. Mutates the form data in-place and returns it for chaining.

pub fn entries(
  of form_data: FormData,
) -> iterator.Iterator(#(String, FormDataValue), Nil, Nil)
pub fn for_each(
  in form_data: FormData,
  run callback: fn(String, FormDataValue) -> a,
) -> Nil
pub fn get(
  from form_data: FormData,
  name name: String,
) -> Result(String, Nil)

Returns the first string value for name, or Error(Nil) if no such key exists or its first value is a file.

pub fn get_all(
  from form_data: FormData,
  name name: String,
) -> List(String)
pub fn get_all_files(
  from form_data: FormData,
  name name: String,
) -> List(file.File)
pub fn get_file(
  from form_data: FormData,
  name name: String,
) -> Result(file.File, Nil)

Returns the first file value for name, or Error(Nil) if no such key exists or its first value is a string.

pub fn has(in form_data: FormData, name name: String) -> Bool
pub fn keys(
  of form_data: FormData,
) -> iterator.Iterator(String, Nil, Nil)
pub fn new() -> FormData
pub fn set(
  in form_data: FormData,
  name name: String,
  value value: String,
) -> FormData

Sets a new value for an existing key, or adds the key if it does not already exist. Mutates the form data in-place and returns it for chaining.

pub fn set_blob(
  in form_data: FormData,
  name name: String,
  value value: blob.Blob,
) -> FormData

Sets a blob value. Mutates the form data in-place and returns it for chaining.

pub fn set_blob_with_filename(
  in form_data: FormData,
  name name: String,
  value value: blob.Blob,
  named filename: String,
) -> FormData

Sets a blob value with a filename. Mutates the form data in-place and returns it for chaining.

pub fn values(
  of form_data: FormData,
) -> iterator.Iterator(FormDataValue, Nil, Nil)
Search Document