Skip to main content

Crate use_extension

Crate use_extension 

Source
Expand description

§use-extension

Practical file extension utility primitives for RustUse.

§Experimental

use-extension is experimental while the use-fs workspace remains below 0.3.0.

§Example

use use_extension::{compound_extension, extension_lowercase};

assert_eq!(extension_lowercase("ARCHIVE.TAR.GZ").as_deref(), Some("gz"));
assert_eq!(compound_extension("archive.tar.gz").as_deref(), Some("tar.gz"));

§Scope

  • extension extraction and normalization
  • compound-extension inspection for common patterns
  • simple extension replacement and removal

§Non-goals

  • MIME sniffing
  • file-format parsing
  • filesystem I/O

§License

Licensed under either of the following, at your option:

  • Apache License, Version 2.0
  • MIT license

Structs§

FileExtension
A string-backed file extension.

Functions§

compound_extension
Extracts a supported compound extension from a file name or path-like input.
extension
Extracts the last simple extension from a file name or path-like input.
extension_lowercase
Extracts the last simple extension and lowercases it.
has_extension
Returns true when a path-like input has a simple extension.
has_extension_eq
Returns true when the last simple extension matches the given candidate.
is_compound_extension
Returns true when the input ends with a supported compound extension.
normalize_extension
Normalizes an extension by removing leading dots and lowercasing it.
with_extension
Replaces the last simple extension or appends one when missing.
without_extension
Removes the last simple extension while preserving directory segments.