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§
- File
Extension - 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
truewhen a path-like input has a simple extension. - has_
extension_ eq - Returns
truewhen the last simple extension matches the given candidate. - is_
compound_ extension - Returns
truewhen 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.