Add some functions to File, so we can generate file instances with content
This commit is contained in:
parent
91de245836
commit
14d92d8b2f
1 changed files with 24 additions and 0 deletions
|
@ -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()
|
||||||
|
|
Loading…
Reference in a new issue