Get rid of tempfile dependency.

This commit is contained in:
Daan de Graaf 2019-01-21 18:22:32 +01:00
parent 599157fa48
commit c6ac5b8963
2 changed files with 32 additions and 6 deletions

View File

@ -129,7 +129,6 @@ tokio-uds = { version="0.2", optional = true }
[dev-dependencies]
env_logger = "0.6"
serde_derive = "1.0"
tempfile = "3.0"
[build-dependencies]
version_check = "0.1"

View File

@ -128,17 +128,30 @@ impl NamedFile {
/// # Examples
///
/// ```rust
/// extern crate tempfile;
/// extern crate actix_web;
///
/// use actix_web::fs::NamedFile;
/// use tempfile::tempfile;
/// use std::io::{self, Write};
/// use std::env;
/// # use std::fs::{self, File};
/// # use std::path::PathBuf;
/// #
/// # fn path() -> PathBuf {
/// # let mut path = env::temp_dir();
/// # path.push("actix-web-named-file-test-from-file");
/// # path
/// # }
/// #
/// # fn tempfile() -> Result<File, io::Error> {
/// # let file = File::create(path())?;
/// # Ok(file)
/// # }
///
/// fn main() -> io::Result<()> {
/// let mut file = tempfile()?;
/// file.write_all(b"Hello, world!")?;
/// let named_file = NamedFile::from_file(file, "foo.txt")?;
/// # fs::remove_file(path())?;
/// Ok(())
/// }
/// ```
@ -169,17 +182,30 @@ impl<C: StaticFileConfig> NamedFile<C> {
/// # Examples
///
/// ```rust
/// extern crate tempfile;
/// extern crate actix_web;
///
/// use actix_web::fs::{NamedFile, DefaultConfig};
/// use tempfile::tempfile;
/// use actix_web::fs::{DefaultConfig, NamedFile};
/// use std::io::{self, Write};
/// use std::env;
/// # use std::fs::{self, File};
/// # use std::path::PathBuf;
/// #
/// # fn path() -> PathBuf {
/// # let mut path = env::temp_dir();
/// # path.push("actix-web-named-file-test-from-file-with-config");
/// # path
/// # }
/// #
/// # fn tempfile() -> Result<File, io::Error> {
/// # let file = File::create(path())?;
/// # Ok(file)
/// # }
///
/// fn main() -> io::Result<()> {
/// let mut file = tempfile()?;
/// file.write_all(b"Hello, world!")?;
/// let named_file = NamedFile::from_file_with_config(file, "foo.txt", DefaultConfig)?;
/// # fs::remove_file(path())?;
/// Ok(())
/// }
/// ```
@ -225,6 +251,7 @@ impl<C: StaticFileConfig> NamedFile<C> {
_cd_map: PhantomData,
})
}
/// Attempts to open a file in read-only mode using provided configuration.
///
/// # Examples