affine_importer 0.1.2

AFFiNE import planning and batching core.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
pub(super) fn file_name(path: &str) -> &str {
  path.rsplit('/').next().unwrap_or(path)
}

pub(super) fn strip_extension(value: &str) -> &str {
  value.rsplit_once('.').map(|(stem, _)| stem).unwrap_or(value)
}

pub(super) fn mime_from_path(path: &str) -> &'static str {
  match path.rsplit('.').next().unwrap_or("").to_lowercase().as_str() {
    "png" => "image/png",
    "jpg" | "jpeg" => "image/jpeg",
    "gif" => "image/gif",
    "webp" => "image/webp",
    "zip" => "application/zip",
    _ => "application/octet-stream",
  }
}