Skip to main content

Module workspace

Module workspace 

Source
Expand description

lex.toml manifest parsing and package resolution.

A lex.toml file marks a project root and declares its package dependencies. Import paths of the form "pkg-name/module" are resolved against this file.

§File format

[package]
name = "lex-web"
version = "0.1.0"

[dependencies]
lex-schema = { path = "../lex-schema" }
# pin to a tag:
lex-schema = { git = "https://github.com/alpibrusl/lex-schema", tag = "v1.2.0" }
# pin to a commit:
lex-schema = { git = "https://github.com/alpibrusl/lex-schema", rev = "abc1234" }
# track a branch:
lex-schema = { git = "https://github.com/alpibrusl/lex-schema", branch = "stable" }
# or from a registry:
lex-schema = { registry = "https://lexhub.alpibru.com", version = "0.9.2" }

At most one of tag, rev, branch may be set; omitting all three clones the default branch at HEAD (not reproducible — pin for releases).

§Module resolution

import "lex-schema/validate" as v splits into pkg = "lex-schema", module = "validate". The loader:

  1. Walks up from the importing file to find the nearest lex.toml.
  2. Looks up lex-schema in [dependencies].
  3. For path =: resolves {dep_path}/src/validate.lex; falls back to {dep_path}/validate.lex if src/ doesn’t exist.
  4. For git =: clones the repo into ~/.lex/packages/lex-schema-<ref>/ (once; subsequent loads hit the cache), then resolves the same way.

Structs§

Manifest
PackageMeta

Enums§

Dependency
PackageError

Functions§

find_manifest
Walk up from start (a file or directory) looking for lex.toml. Returns (toml_path, toml_dir) for the nearest ancestor that has one.
resolve_package_import
Resolve pkg_name/module_path to a .lex file on disk.