use std::fs::{
Metadata,
metadata
};
#[derive(Debug)]
pub struct HastebinFile {
buffer: String,
path: String
}
fn get_max_bytes_upload() -> u64 {
52428800
}
impl HastebinFile {
pub fn new(buffer: String, path: String) -> HastebinFile {
HastebinFile{
buffer: buffer,
path: path
}
}
pub fn is_too_big(&self) -> bool {
let file_metadata: Metadata = metadata(self.get_path()).expect("Cannot get file metadata");
file_metadata.len() >= get_max_bytes_upload()
}
pub fn get_buffer(&self) -> String {
self.buffer.clone()
}
pub fn get_path(&self) -> &str {
&self.path
}
}