Skip to main content

Router

Struct Router 

Source
pub struct Router { /* private fields */ }
Expand description

User-level map of project name to layout, plus the process default.

Implementations§

Source§

impl Router

Source

pub fn unrouted(default: Layout) -> Self

A router that never leaves default. Used when routing is off.

Source

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.

Source

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.

Source

pub fn default_layout(&self) -> &Layout

The process default, from --root / VISSUE_ROOT / cwd.

Source

pub fn is_routed(&self) -> bool

Whether any route is configured.

Source

pub fn route(&self, project: &str) -> ProjectRef

Resolve a caller-facing project name to a layout and on-disk directory.

Source

pub fn unique_layouts(&self) -> Vec<&Layout>

Unique layouts, default first, then named ones. Equality is (canonical root, prefix).

Source

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.

Source

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.

Source

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.

Source

pub fn duplicate_ids(&self) -> Result<Vec<(String, Vec<PathBuf>)>>

Ids that appear under more than one distinct unique layout.

§Errors

Returns an error if a project file cannot be read.

Trait Implementations§

Source§

impl Clone for Router

Source§

fn clone(&self) -> Router

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Router

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.