pub struct FileExt;Implementations§
source§impl FileExt
impl FileExt
pub fn read_file_partially(
filepath: &str,
range: &Range
) -> Result<Vec<u8>, String>
sourcepub fn read_file(filepath: &str) -> Result<Vec<u8>, String>
pub fn read_file(filepath: &str) -> Result<Vec<u8>, String>
Examples found in repository?
src/lib.rs (line 116)
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
pub fn read_or_create_and_write(path: &str, content: &[u8]) -> Result<Vec<u8>, String> {
let does_passphrase_exist = Self::does_file_exist(path);
return if does_passphrase_exist {
let boxed_read = Self::read_file(path);
if boxed_read.is_err() {
return Err(boxed_read.err().unwrap());
}
let passphrase = boxed_read.unwrap();
Ok(passphrase)
} else {
let boxed_create = Self::create_file(path);
if boxed_create.is_err() {
let message = boxed_create.err().unwrap();
return Err(message)
}
let boxed_write = Self::write_file(path, content);
if boxed_write.is_err() {
let message = boxed_write.err().unwrap();
return Err(message)
}
Ok(Vec::from(content))
}
}pub fn file_modified_utc(filepath: &str) -> Result<u128, String>
pub fn get_static_filepath(request_uri: &str) -> Result<String, String>
pub fn read_or_create_and_write(
path: &str,
content: &[u8]
) -> Result<Vec<u8>, String>
sourcepub fn create_file(path: &str) -> Result<File, String>
pub fn create_file(path: &str) -> Result<File, String>
Examples found in repository?
src/lib.rs (line 123)
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
pub fn read_or_create_and_write(path: &str, content: &[u8]) -> Result<Vec<u8>, String> {
let does_passphrase_exist = Self::does_file_exist(path);
return if does_passphrase_exist {
let boxed_read = Self::read_file(path);
if boxed_read.is_err() {
return Err(boxed_read.err().unwrap());
}
let passphrase = boxed_read.unwrap();
Ok(passphrase)
} else {
let boxed_create = Self::create_file(path);
if boxed_create.is_err() {
let message = boxed_create.err().unwrap();
return Err(message)
}
let boxed_write = Self::write_file(path, content);
if boxed_write.is_err() {
let message = boxed_write.err().unwrap();
return Err(message)
}
Ok(Vec::from(content))
}
}sourcepub fn does_file_exist(path: &str) -> bool
pub fn does_file_exist(path: &str) -> bool
Examples found in repository?
src/lib.rs (line 114)
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
pub fn read_or_create_and_write(path: &str, content: &[u8]) -> Result<Vec<u8>, String> {
let does_passphrase_exist = Self::does_file_exist(path);
return if does_passphrase_exist {
let boxed_read = Self::read_file(path);
if boxed_read.is_err() {
return Err(boxed_read.err().unwrap());
}
let passphrase = boxed_read.unwrap();
Ok(passphrase)
} else {
let boxed_create = Self::create_file(path);
if boxed_create.is_err() {
let message = boxed_create.err().unwrap();
return Err(message)
}
let boxed_write = Self::write_file(path, content);
if boxed_write.is_err() {
let message = boxed_write.err().unwrap();
return Err(message)
}
Ok(Vec::from(content))
}
}sourcepub fn write_file(path: &str, file_content: &[u8]) -> Result<(), String>
pub fn write_file(path: &str, file_content: &[u8]) -> Result<(), String>
Examples found in repository?
src/lib.rs (line 129)
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
pub fn read_or_create_and_write(path: &str, content: &[u8]) -> Result<Vec<u8>, String> {
let does_passphrase_exist = Self::does_file_exist(path);
return if does_passphrase_exist {
let boxed_read = Self::read_file(path);
if boxed_read.is_err() {
return Err(boxed_read.err().unwrap());
}
let passphrase = boxed_read.unwrap();
Ok(passphrase)
} else {
let boxed_create = Self::create_file(path);
if boxed_create.is_err() {
let message = boxed_create.err().unwrap();
return Err(message)
}
let boxed_write = Self::write_file(path, content);
if boxed_write.is_err() {
let message = boxed_write.err().unwrap();
return Err(message)
}
Ok(Vec::from(content))
}
}