INNER CODE UNIT · Rust
has_file
szabodanika/microbin · src/pasta.rs:104
pub fn has_file(&self) -> bool {
self.file.is_some()
}
pub fn total_size_as_string(&self) -> String {
let mut total_size_bytes = self.content.as_bytes().len();
if let Some(file) = &self.file {
total_size_bytes += file.size.as_u64() as usize;
}
if let Some(attachments) = &self.attachments {
for attachment in attachments {
total_size_bytes += attachment.size.as_u64() as usize;
}
}
if total_size_bytes < 1024 {
format!("{} B", total_size_bytes)
} else if total_size_bytes < 1024 * 1024 {