Skip to main content

PathDisplayExt

Trait PathDisplayExt 

Source
pub trait PathDisplayExt {
    // Required methods
    fn display_posix(&self) -> String;
    fn posix(&self) -> PathPosix<'_>;
}
Expand description

Display-only extension for human-facing path output. On Windows, folds \/ so a status subject or error message shows POSIX-form paths consistently across runners. On Unix, passes through unchanged — a legitimate \ in a Unix filename survives byte-for-byte.

display_posix() is the eager form (returns String). posix() is the lazy form — returns impl Display so it composes with format!/write!/println! without an intermediate allocation.

Use in:

  • Printer status subjects (status[_simple], kv values, error messages)
  • tracing::info!/warn!/error! event fields where the path is the human-visible value

Do NOT use in:

  • JSON / YAML / SQLite / OCI / gateway boundaries — use to_posix_string instead (always folds, not Windows-only)
  • Debug-only tracing::debug!/trace! event fields — keep native so debug tooling sees what’s on disk

Required Methods§

Source

fn display_posix(&self) -> String

Eager: returns a String with \ folded to / on Windows, native on Unix.

Source

fn posix(&self) -> PathPosix<'_>

Lazy: returns a Display adapter suitable for format! / write!.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§