#totto2727/x/path

Provides normalized absolute and relative filesystem path value types that preserve their form through parsing, joining, and JSON conversion. See the module README for consumer setup and package imports.

#Usage

Resolve a relative source path against a workspace while normalizing parent-directory segments.

///|
test {
let base = AbsolutePath::from_string("/workspace/project")
let child = RelativePath::from_string("src/../README.md")
assert_eq(Path::join(base, child).to_string(), "/workspace/project/README.md")
}

#Package behavior

  • Separates normalized absolute and relative path forms at construction.
  • Permits joins only with validated RelativePath values.
  • Encodes values as normalized JSON strings and rejects mismatched forms on decoding.

#API

This README was generated from the share-artifact skill and README template.

Path

pub(open) trait Path {
fn from_string(String) -> Self raise
fn to_string(Self) -> String
fn join(Self, RelativePath) -> Self
}

Describes a normalized filesystem path value.

join accepts a relative path so implementations can preserve their path form without revalidating the result.

AbsolutePath

pub struct AbsolutePath {
path :
Path

} derive(Eq,
Debug
)

A normalized absolute filesystem path.

AbsolutePath::AbsolutePath

fn AbsolutePath::AbsolutePath(path :
Path
) -> AbsolutePath raise

Constructs a normalized absolute path.

AbsolutePath::from_string

fn AbsolutePath::from_string(value : String) -> AbsolutePath raise

AbsolutePath::to_json

fn AbsolutePath::to_json(self : AbsolutePath) -> Json

AbsolutePath::to_string

fn AbsolutePath::to_string(self : AbsolutePath) -> String

RelativePath

pub struct RelativePath {
path :
Path

} derive(Eq,
Debug
)

A normalized relative filesystem path.

RelativePath::RelativePath

fn RelativePath::RelativePath(path :
Path
) -> RelativePath raise

Constructs a normalized relative path.

RelativePath::from_string

fn RelativePath::from_string(value : String) -> RelativePath raise

RelativePath::to_json

fn RelativePath::to_json(self : RelativePath) -> Json

RelativePath::to_string

fn RelativePath::to_string(self : RelativePath) -> String

Source Files

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io