actix_multipart_rfc7578/
lib.rs

1// Copyright 2017 rust-multipart-rfc7578 Developers
2//
3// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
4// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5// http://opensource.org/licenses/MIT>, at your option. This file may not be
6// copied, modified, or distributed except according to those terms.
7//
8
9//! This crate contains an implementation of the multipart/form-data media
10//! type described in [RFC 7578](https://tools.ietf.org/html/rfc7578) for
11//! [actix-web](https://github.com/actix/actix-web).
12//!
13//! ## Usage
14//!
15//! Declare the dependency:
16//!
17//! ```toml
18//! [dependencies]
19//! actix-multipart-rfc7578 = "0.11"
20//! ```
21//!
22//! Import the crate:
23//!
24//! ```rust
25//! use actix_multipart_rfc7578 as multipart;
26//! ```
27//!
28//! ## Example:
29//!
30//! ```rust
31//! use actix_multipart_rfc7578::client::{self, multipart};
32//! use awc::Client;
33//!
34//! #[actix_rt::main]
35//! async fn main() {
36//!     let mut form = multipart::Form::default();
37//!
38//!     form.add_text("test", "Hello World");
39//!
40//!     let response = Client::default()
41//!         .get("http://localhost/upload")
42//!         .content_type(form.content_type())
43//!         .send_body(multipart::Body::from(form))
44//!         .await;
45//!
46//!     if let Ok(_) = response {
47//!         println!("done...");
48//!     } else {
49//!         eprintln!("an error occurred");
50//!     }
51//! }
52//! ```
53
54#![allow(clippy::needless_doctest_main)]
55
56use common_multipart_rfc7578 as common_multipart;
57
58mod body;
59
60pub mod client {
61    pub use crate::common_multipart::client::Error;
62
63    pub mod multipart {
64        pub use crate::body::Body;
65        pub use crate::common_multipart::client::multipart::{BoundaryGenerator, Form};
66    }
67}