From 14d92d8b2fbff23d21e59e7a4cdf1f3a56377e54 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 23 Nov 2015 19:27:54 +0100 Subject: [PATCH] Add some functions to File, so we can generate file instances with content --- src/storage/file.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/storage/file.rs b/src/storage/file.rs index c80d99ae..505a6452 100644 --- a/src/storage/file.rs +++ b/src/storage/file.rs @@ -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 { use uuid::Uuid; Uuid::new_v4().to_hyphenated_string()