Move types to types.rs
This commit is contained in:
parent
7714fba5b5
commit
0f681ca903
|
@ -17,7 +17,7 @@ mod types;
|
|||
mod upload;
|
||||
pub use self::error::Error;
|
||||
pub use self::types::*;
|
||||
pub use self::upload::{handle_upload, MultipartForm, MultipartHash};
|
||||
pub use self::upload::handle_upload;
|
||||
|
||||
pub trait FilenameGenerator: Send + Sync {
|
||||
fn next_filename(&self, &mime::Mime) -> Option<PathBuf>;
|
||||
|
|
17
src/types.rs
17
src/types.rs
|
@ -1,4 +1,4 @@
|
|||
use std::{fmt, collections::VecDeque, sync::Arc};
|
||||
use std::{fmt, collections::VecDeque, path::PathBuf, sync::Arc};
|
||||
|
||||
use futures::{Future, future::{ExecuteError, Executor}};
|
||||
use futures_cpupool::CpuPool;
|
||||
|
@ -272,3 +272,18 @@ impl Executor<Box<Future<Item = (), Error = ()> + Send>> for ArcExecutor where {
|
|||
self.inner.execute(future)
|
||||
}
|
||||
}
|
||||
|
||||
pub type MultipartHash = (Vec<NamePart>, MultipartContent);
|
||||
|
||||
pub type MultipartForm = Vec<MultipartHash>;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum MultipartContent {
|
||||
File {
|
||||
filename: String,
|
||||
stored_as: PathBuf,
|
||||
},
|
||||
Text(String),
|
||||
Int(i64),
|
||||
Float(f64),
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{fs::DirBuilder, os::unix::fs::DirBuilderExt, path::{Path, PathBuf}, sync::Arc};
|
||||
use std::{fs::DirBuilder, os::unix::fs::DirBuilderExt, path::Path, sync::Arc};
|
||||
|
||||
use actix_web::{multipart, error::PayloadError};
|
||||
use bytes::{Bytes, BytesMut};
|
||||
|
@ -8,22 +8,7 @@ use http::header::CONTENT_DISPOSITION;
|
|||
|
||||
use error::Error;
|
||||
use super::FilenameGenerator;
|
||||
use types::{self, NamePart};
|
||||
|
||||
pub type MultipartHash = (Vec<NamePart>, MultipartContent);
|
||||
|
||||
pub type MultipartForm = Vec<MultipartHash>;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum MultipartContent {
|
||||
File {
|
||||
filename: String,
|
||||
stored_as: PathBuf,
|
||||
},
|
||||
Text(String),
|
||||
Int(i64),
|
||||
Float(f64),
|
||||
}
|
||||
use types::{self, MultipartContent, MultipartForm, MultipartHash, NamePart};
|
||||
|
||||
fn parse_multipart_name(name: String) -> Result<Vec<NamePart>, Error> {
|
||||
name.split('[')
|
||||
|
|
Loading…
Reference in a new issue