Struct tempfile::NamedTempFileOptions
[−]
[src]
pub struct NamedTempFileOptions<'a, 'b> { // some fields omitted }
Create a new temporary file with custom parameters.
Example
use tempfile::NamedTempFileOptions; let named_temp_file = NamedTempFileOptions::new() .prefix("hogehoge") .suffix(".rs") .rand_bytes(5) .create() .unwrap(); let name = named_temp_file.path() .file_name().unwrap() .to_str().unwrap(); assert!(name.starts_with("hogehoge")); assert!(name.ends_with(".rs")); assert_eq!(name.len(), "hogehoge.rs".len() + 5);
Methods
impl<'a, 'b> NamedTempFileOptions<'a, 'b>
fn new() -> Self
Create a new NamedTempFileOptions
fn prefix(&mut self, prefix: &'a str) -> &mut Self
Set a custom filename prefix.
Path separators are legal but not advisable. Default: ".tmp"
fn suffix(&mut self, suffix: &'b str) -> &mut Self
Set a custom filename suffix.
Path separators are legal but not advisable. Default: ""
fn rand_bytes(&mut self, rand: usize) -> &mut Self
Set the number of random bytes.
Default: 6
fn create(&self) -> Result<NamedTempFile>
Create the named temporary file.
fn create_in<P: AsRef<Path>>(&self, dir: P) -> Result<NamedTempFile>
Create the named temporary file in the specified directory.