Add some functions to File, so we can generate file instances with content

This commit is contained in:
Matthias Beyer 2015-11-23 19:27:54 +01:00
parent 91de245836
commit 14d92d8b2f

View file

@ -185,6 +185,30 @@ impl File {
} }
} }
pub fn new_with_header(h: FileHeaderData) -> File {
File {
header: h,
data: String::from(""),
id: File::get_new_file_id(),
}
}
pub fn new_with_data(d: String) -> File {
File {
header: FileHeaderData::Null,
data: d,
id: File::get_new_file_id(),
}
}
pub fn new_with_content(h: FileHeaderData, d: String) -> File {
File {
header: h,
data: d,
id: File::get_new_file_id(),
}
}
fn get_new_file_id() -> FileID { fn get_new_file_id() -> FileID {
use uuid::Uuid; use uuid::Uuid;
Uuid::new_v4().to_hyphenated_string() Uuid::new_v4().to_hyphenated_string()