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 extra_id_paths_for(&self, dir: &str) -> Vec<PathBuf>
pub fn extra_id_paths_for(&self, dir: &str) -> Vec<PathBuf>
The twin files an id reservation has to read, rather than the ids in them.
Reading the ids here and minting later is a read outside the lock that
protects the write. Two creates for the same project in two roots each
see the other’s file before either has written, take different locks,
because the locks are per file, and can mint the same suffix. A duplicate
across layouts is not a cosmetic clash: find_by_id reports
DuplicateId for it, so the issue becomes unreachable by id.
So the caller hands over paths and the mint reads them under the same lock set it writes under.
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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Router
impl RefUnwindSafe for Router
impl Send for Router
impl Sync for Router
impl Unpin for Router
impl UnsafeUnpin for Router
impl UnwindSafe for Router
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more