Nebula_Form

nebula_form is a small Rust library that provides a simple interface for working with form data.

Features

Non-Features

Usage

```rust use nebula_form::{Form, Field}; use warp::Filter;

fn main() { let form = Form::new(); form.insert("field-foo", Field::Text(String::from("contents")));

// Don't use `panic!` in actual code
match form.get("field-foo") {
    None => panic!("Field expected"),
    Some(field) => {
        match field {
            Field::Text(txt) => println!(txt),
            Field::File(_) => panic!("This should not be a file!"),
        }
    }
}

// `make_request` doesn't actually exist and stands in for any usual way
// of creating an HTTP request.
make_request("POST", form.to_url_encoded().as_bytes());
make_request("POST", form.to_multipart_bytes());

// When using warp, the `form_filter` function parses the request body into
// a `Form`.
let hi = warp::path("some-form")
    .and(warp::method::post())
    .and(nebula_form::form_filter())
    .map(|form: Form| {
        format!("Hello {}!", form.get("name").unwrap())
    });

} ```