paved 0.6.0

A simple platform agnostic path representation
Documentation
use std::{ffi::OsString, path::PathBuf};

#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

use crate::{PathPrefix, PathType};

mod accessors;
mod builder_mutators;
mod converters;
mod initializers;
mod internal;
mod mutators;
mod trait_impls;

/// A platform agnostic path representation.
///
/// This struct stores all relevant path information internally in a platform agnostic way, and builds paths for the specific platform as needed.
/// A path for a specific platform/in a specific style can be built using [`PavedPath::path_in_style()`].
///
/// This struct also implements [`AsRef<PathBuf>`] so it can be used in place of other [`PathBuf`] without manual conversion.
/// The [PathBuf] returned through [`AsRef<PathBuf>`] always uses the style of the platform the binary was built for.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(from = "PathBuf", into = "PathBuf"))]
#[derive(Debug, Clone, Hash, Eq, PartialEq, PartialOrd, Ord, Default)]
pub struct PavedPath {
    pub(crate) path_type: PathType,
    pub(crate) path_prefix: Option<PathPrefix>,
    pub(crate) directories: Vec<OsString>,
    pub(crate) file: Option<OsString>,
    pub(crate) inner: PathBuf,
}