pub struct Router { /* private fields */ }Expand description
User-level map of project name to layout, plus the process default.
Implementations§
Source§impl Router
impl Router
Sourcepub fn unrouted(default: Layout) -> Self
pub fn unrouted(default: Layout) -> Self
A router that never leaves default. Used when routing is off.
Sourcepub fn load(default: Layout) -> Result<Self>
pub fn load(default: Layout) -> Result<Self>
Load $VISSUE_CONFIG or the XDG file over default.
A missing default-path file is a no-op. VISSUE_NO_ROUTE set to a
non-empty value other than 0 / false ignores the file.
§Errors
Returns an error if an explicit VISSUE_CONFIG path is missing, the
file cannot be read or parsed, a route names an unknown layout, or a
layout root is relative after expansion.
Sourcepub fn from_file(default: Layout, path: &Path) -> Result<Self>
pub fn from_file(default: Layout, path: &Path) -> Result<Self>
Load an explicit config file. Tests and callers that already resolved the path use this.
§Errors
Same as Self::load.
Sourcepub fn default_layout(&self) -> &Layout
pub fn default_layout(&self) -> &Layout
The process default, from --root / VISSUE_ROOT / cwd.
Sourcepub fn route(&self, project: &str) -> ProjectRef
pub fn route(&self, project: &str) -> ProjectRef
Resolve a caller-facing project name to a layout and on-disk directory.
Sourcepub fn unique_layouts(&self) -> Vec<&Layout>
pub fn unique_layouts(&self) -> Vec<&Layout>
Unique layouts, default first, then named ones. Equality is
(canonical root, prefix).
Sourcepub fn visible_projects(&self) -> Result<Vec<ProjectRef>>
pub fn visible_projects(&self) -> Result<Vec<ProjectRef>>
Projects an unscoped list / projects should show.
Default-layout directories whose name is an identity route key are hidden. Alias keys appear; the alias directory on the routed layout does not appear under its raw name unless that name is also a default project.
§Errors
Returns an error if a projects directory cannot be read.
Sourcepub fn extra_ids_for(&self, dir: &str) -> Result<Vec<String>>
pub fn extra_ids_for(&self, dir: &str) -> Result<Vec<String>>
Ids already used for dir on any unique layout, so a create can
refuse a suffix the twin file already holds.
§Errors
Returns an error if a twin file exists and cannot be parsed.
Sourcepub fn find_by_id(&self, id: &str) -> Result<RouteHit>
pub fn find_by_id(&self, id: &str) -> Result<RouteHit>
Locate one id. The longest matching route key or known project directory is tried first; then every remaining unique layout.
§Errors
Error::IssueNotFound when no layout has the id.
Error::DuplicateId when two distinct layouts define it.