Skip to main content

Crate use_fs

Crate use_fs 

Source
Expand description

§use-fs

Composable filesystem-adjacent primitives for RustUse.

§Experimental

use-fs is experimental while the workspace remains below 0.3.0. Expect API adjustments as the first wave settles.

§Example

#[cfg(feature = "full")]
use use_fs::*;

#[cfg(feature = "full")]
{
    assert_eq!(path_kind("docs/guide.md"), PathKind::Relative);
    assert_eq!(normalize_extension(".TAR.GZ"), "tar.gz");
    assert_eq!(sanitize_file_name("report?.txt"), "report-.txt");
}

§Scope

  • feature-gated access to the focused use-fs crates
  • direct reexports for path, file-name, extension, directory, and stem helpers
  • one dependency for callers that want the full first-wave workspace

§Non-goals

  • adding filesystem I/O APIs
  • hiding crate boundaries behind heavy abstraction
  • replacing std::path or std::fs

§License

Licensed under either of the following, at your option:

  • Apache License, Version 2.0
  • MIT license

Re-exports§

pub use use_dir as dir;
pub use use_extension as extension;
pub use use_file_name as file_name;
pub use use_file_stem as file_stem;
pub use use_path as path;

Structs§

DirectoryPath
A string-backed directory path.
FileExtension
A string-backed file extension.
FileName
A string-backed file name.
FileStem
A string-backed file stem.
PathParts
A lexical view of a path-like input.

Enums§

PathKind
Classifies a path-like input using a small lexical model.
PathSeparator
Describes which separator styles appear in a path-like input.

Functions§

append_to_file_stem
Appends a suffix to the file stem while preserving the original extension suffix.
compound_extension
Extracts a supported compound extension from a file name or path-like input.
detect_path_separator
Detects which path separator style appears in the input.
dir_name
Extracts the most relevant directory segment from a path-like input.
ensure_dir_trailing_separator
Ensures a trailing / for non-empty directory paths.
ensure_trailing_separator
Ensures a trailing / for non-empty input.
extension
Extracts the last simple extension from a file name or path-like input.
extension_from_path
Extracts the final simple extension from a path-like input.
extension_lowercase
Extracts the last simple extension and lowercases it.
file_name
Extracts the final file-name segment from a path-like input.
file_name_from_path
Extracts the final file-name segment from a path-like input.
file_stem
Extracts the simple file stem from a file name or path-like input.
file_stem_without_compound_extension
Extracts the file stem while removing a supported compound extension when present.
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.
has_file_stem
Returns true when the input has a recoverable file stem.
has_reserved_file_name
Returns true when the extracted file name is a reserved Windows name.
is_absolute_path
Returns true when the input begins with a recognized absolute prefix.
is_compound_extension
Returns true when the input ends with a supported compound extension.
is_current_dir
Returns true when the input refers to the current directory.
is_empty_path
Returns true when the input is empty.
is_hidden_file_name
Returns true when the extracted file name is a hidden dotfile.
is_parent_dir
Returns true when the input refers to the parent directory.
is_relative_path
Returns true when the input is non-empty and not absolute.
is_root_dir
Returns true when the input is a recognized root directory.
is_safe_file_name
Returns true when the extracted file name avoids reserved names and unsafe characters.
join_path_parts
Joins path parts with / while preserving a leading absolute prefix when present.
normalize_dir_path
Normalizes directory separators to / and removes trailing separators unless the input is a root.
normalize_extension
Normalizes an extension by removing leading dots and lowercasing it.
normalize_file_name
Normalizes a file name by trimming surrounding whitespace.
normalize_path_separators
Normalizes path separators to /.
parent_path
Extracts the lexical parent path when one is present.
path_depth
Returns the lexical depth of a directory path.
path_kind
Returns the lexical kind for a path-like input.
path_parts
Returns lexical directory, file-name, and extension parts.
prepend_to_file_stem
Prepends a prefix to the file stem while preserving the original extension suffix.
relative_to_dir
Computes a lexical relative path when base is a prefix of path.
remove_unsafe_file_name_chars
Removes unsafe characters and control characters from a file name.
replace_unsafe_file_name_chars
Replaces unsafe characters and control characters with a safe replacement.
sanitize_file_name
Sanitizes a file name by trimming, replacing unsafe characters, and disarming reserved names.
slug_file_stem_basic
Converts a file stem into a conservative ASCII slug.
split_path_parts
Splits a path-like input into normalized non-empty segments.
starts_with_dir
Returns true when the input starts with the given directory on segment boundaries.
strip_dir_trailing_separator
Removes trailing separators while preserving roots.
trim_trailing_separator
Removes trailing separators while preserving recognized roots.
with_extension
Replaces the last simple extension or appends one when missing.
with_file_stem
Replaces the file stem while preserving the original extension suffix.
without_extension
Removes the last simple extension while preserving directory segments.